Text Diff

Paste an original and a changed version of a text to see exactly which lines were added, removed or edited, with the changed words highlighted inside each edited line.

Both texts are compared inside your browser and are never sent to our server.

How to use the Text Diff

  1. Paste the earlier version of your text on the left and the newer version on the right. Code, contracts, essays and lists all work.
  2. Choose your options: ignore whitespace (useful when only indentation or spacing changed), ignore case, and whether to highlight the changed words inside edited lines.
  3. Press Compare. Removed lines are shown in red with a minus sign, added lines in green with a plus sign, and each line keeps its original line number.
  4. Click Show unchanged lines to expand a folded section, or press Copy as unified diff to paste the changes into an email, a ticket or a code review.

How the comparison works

The tool splits both texts into lines and finds the longest set of lines the two versions have in common, in order. It uses Eugene Myers' O(ND) difference algorithm, which is also the default algorithm in git diff, and returns the smallest set of line insertions and deletions that turns the original into the changed version. Everything that is not part of that common set is marked as removed or added.

When a block of removed lines sits directly next to a block of added lines, the tool pairs them up and runs a second, word-level diff on each pair. That is what produces the darker highlights: you can see that only a date or a single word changed instead of reading two near-identical lines side by side.

Tips and limitations

Frequently asked questions

Is my text uploaded to compare it?

No. Both texts stay in your browser tab and the comparison is done by JavaScript on your device. Nothing is sent to our server or saved.

Why does a line show as removed and added when only one word changed?

Because the diff works line by line, an edited line is a removed old line plus an added new line. With Highlight changed words switched on, the exact words that changed inside that pair are highlighted so you do not have to hunt for them.

Can I compare code or JSON?

Yes. The tool treats all input as plain text and shows it in a monospaced font. For JSON, format both versions the same way first (for example with the JSON Formatter) so that layout differences do not hide the real changes.

Does it handle Windows and Mac line endings?

Yes. CRLF and CR line endings are converted to plain line feeds before comparing, so a file saved on Windows and the same file saved on Linux compare as identical.

What does the unified diff format look like?

Each changed region starts with a header such as @@ -12,7 +12,8 @@, meaning the region starts at line 12 and is 7 lines long in the original and 8 in the changed text. Lines starting with a minus were removed, a plus were added, and a space are unchanged context.

Sources: Git documentation: --diff-algorithm option

Related tools