Text tool

Diff Checker: Compare Two Texts Online (Text Compare)

Compare two texts online and see the differences, with changed words highlighted, side by side or inline. Ignore whitespace or case. Nothing is uploaded.

Last updated

Paste two versions of a text and see what changed: added lines in green, removed lines in red, and the changed words inside each edited line highlighted.

View

Comparing...

The diff updates as you type. On a phone it shows Inline, one column with removed lines above the lines that replaced them; on a wider screen it shows the two texts Side by side, and either view is a tap away. Ignore whitespace and Ignore case hide changes you do not care about, Swap flips which text is the original, and Copy diff copies the result as a unified diff. Everything runs in your browser and nothing is uploaded.

How to read the diff

You seeIt means
A red lineIn the original, gone from the changed text
A green lineNew in the changed text
A red line next to a green oneThe line was edited; the darker highlight is what changed inside it
Two line numbers (inline view)The line's number in the original, then in the changed text
"Show 12 unchanged lines"Lines that are the same in both, folded away. Tap to open them

An edited line counts as one line removed and one added, which is how git diff and GitHub count it too. So "3 lines added, 3 lines removed" can mean three lines were edited and nothing else.

Options, and when to use them

OptionTurn it on when
Ignore whitespaceCode was re-indented, tabs became spaces, or an editor trimmed trailing spaces
Ignore caseComparing SQL keywords, email addresses, headings or anything where Cat and cat mean the same
SwapYou pasted them the wrong way round, and the additions show as removals

Ignore whitespace trims each line and treats any run of spaces or tabs as one space. It does not ignore blank lines, and it does not join words, so can not against cannot is still a change.

Line endings are normalised

Windows ends each line with two characters, CR and LF (\r\n). macOS and Linux use LF alone (\n). Compare the same file saved on both and a naive diff marks every line as changed, although nothing you can see is different.

This tool turns every line ending into LF before comparing, so only real changes show, and it tells you when the two texts used different endings. It also treats a missing line break at the very end as no change. If the line endings are the thing you need to check, git diff or file in a terminal will show them.

Common gotchas

  • Everything is different. A whole-file re-indent or a tabs-to-spaces switch. Turn on Ignore whitespace.
  • Moved lines show as removed and added. A diff finds the smallest set of additions and removals; it has no idea of "moved". A block moved from the top to the bottom shows as removed in one place and added in another.
  • Reformatted JSON or SQL looks completely changed. Format both versions the same way first, with the JSON Formatter or the SQL Formatter, then compare. The diff then shows only what changed in the data or the query.
  • Invisible characters. A non-breaking space or a zero-width space looks like nothing but is a different character. If two lines look identical and still show as changed, one of these is the usual reason.

How it works

  1. Both texts are split into lines, with CRLF and CR line endings turned into LF.
  2. Each line gets a comparison key: the line itself, or a trimmed or lower-cased version when an ignore option is on. The text you see is never changed.
  3. The keys are compared with jsdiff, an open source implementation of the Myers diff algorithm, the same approach git diff uses. It finds the fewest additions and removals that turn one list of lines into the other.
  4. Inside each run of changes, removed lines are paired with added lines in order, and each pair is compared again word by word for the highlights.

The comparison runs in a Web Worker, a background thread in your browser, so two 10,000-line pastes never freeze the page.

Common questions

What is a diff checker?

A diff checker, also called a text compare tool, takes two versions of a text and shows what changed between them: lines that were added, lines that were removed, and the words that changed inside an edited line. The name comes from diff, the Unix command that has done the same job in a terminal since the 1970s.

How do I compare two texts online?

Paste the first version into Original text and the second into Changed text at the top of this page. The differences appear under them as you type: removed lines in red, added lines in green, and the changed words inside an edited line highlighted more strongly. The count of lines added and removed sits above the diff.

Is this online diff tool private?

Yes. The comparison runs in your browser, in a background thread, and neither text is sent to a server, so it is safe for code, configs and contracts. The site records that the tool was used, with the options chosen and how many lines changed, but never the text itself.

Why does every line show as changed?

Usually because the whole text was re-indented, or tabs were swapped for spaces. Turn on Ignore whitespace and only the real changes are left. Different line endings, Windows CRLF against Unix LF, are the other classic cause, and this tool already normalises those before comparing, so they never show up as changes.

What does ignore whitespace do?

It treats two lines as the same when they differ only in spacing: indentation, trailing spaces, and the number of spaces or tabs between words. Blank lines still count, and a space inside a word, such as in 'can not' against 'cannot', is still a change. The diff still shows each line exactly as it was typed.

Can I compare code or files with it?

Yes. Paste the contents of each file into the two boxes. It compares any plain text, code in any language included, and Copy diff gives you the result as a unified diff, the same format git diff prints, which git apply and patch can read. To compare files in a repository, git diff or diff -u in a terminal does the same job.

How large a text can it compare?

Tens of thousands of lines. The work runs in the background so the page keeps responding, and only the changes plus three lines around each one are drawn, with the unchanged stretches folded away until you open them. Two very large texts that have almost nothing in common are compared more roughly, and the page says when that happens.

See all tools

Want this explained by a cat?

The videos cover the same ground in sixty seconds. If there is a tool you want built next, ask.