Diff Checker: Compare Two Texts

Paste the old version on the left and the new one on the right. Added, removed and changed lines are marked right away, down to the words that changed.

Ignore
View

Paste two texts to see what changed. Shortcut: Ctrl or Cmd + Enter.

Your texts are compared on this device and are not uploaded to any server.

How to use it

  1. Paste the old text into Original text and the new version into Changed text, or load a text file (.txt, .csv, source code) with Open file.
  2. The differences appear below as you type. Lines marked - are only in the original, lines marked + only in the changed text. Inside a changed line the old words are struck through and the new ones underlined.
  3. Tick the options under Ignore when differences in case, spacing or blank lines don't matter to you.
  4. Press Copy diff to copy the result as a unified diff, for example to send it to a colleague or keep it with a revision.

How the differences are found

Both texts are split into lines. The tool then looks for the longest common subsequence: the lines that appear in both texts in the same order. Every line outside that sequence is a difference. The search uses Myers' algorithm (1986), the same one Git and GNU diff use, so as few lines as possible are marked.

Then, in each block of changes, every removed line is paired with the most similar added line. Each pair is compared again word by word, and words that differ by a letter or two (say color and colour) are compared letter by letter. Numbers are marked whole, so 100 changing to 120 shows as one number replaced.

Example

Original: Buy rice, Buy sugar, Pay electricity, Pick up Sam, Wash the car (5 lines). Changed: Buy rice, Pay electricity, Pay water, Pick up Sam at 4, Wash the car. The longest common subsequence is 3 lines: Buy rice, Pay electricity, Wash the car. The rest gives this result:

LineMarkResult
Buy sugar-Removed
Pay water+Added, not similar to any old line
Pick up Sam → Pick up Sam at 4- and +Changed, " at 4" underlined
The other 3 linesspaceSame

What the Ignore options do

  • Upper/lower case: "London" counts as the same as "LONDON".
  • Spacing: a run of spaces or tabs counts as one space, and spaces at the start and end of a line are ignored. "a b" equals "a b", but "ab" still differs from "a b".
  • Blank lines: lines that are empty or contain only spaces are left out of the comparison. They are still shown, without a mark.

Limits

Windows (CRLF) and Linux/Mac (LF) line endings count as the same, and so does a missing line break at the very end. The Side by side view needs a screen at least 760 pixels wide; on narrower screens the result is shown in one column. Very long texts that have little in common are compared with a faster method that does not always find the shortest diff; the tool says when that happens.

Questions

Is the text I paste sent to a server?
No. The comparison runs in your browser, on your device. The text is not uploaded anywhere and is gone when you close the page.
When is a line counted as "changed" rather than removed and added?
Within a block of changes, an old line and a new line are paired when they are similar, meaning they share at least 40% of their letter pairs or words, or when the block replaces exactly as many lines as it removes. Pairs count as Changed and the words that differ are marked. Lines without a partner count as Removed or Added.
Why does a paragraph I barely edited show up as completely different?
The comparison works line by line. If the same text is broken into lines at different places, for instance after copying it from a PDF, every line shifts and looks changed. Join the lines first with Join lines in the Case Converter, then compare again.
Does it detect lines that were moved?
Not as "moved". A line that moved shows as removed in its old place and added in its new one. Git and the diff command show it the same way.
What does a line like @@ -12,7 +12,8 @@ in the copied diff mean?
It is a hunk header in the unified diff format: the block starts at line 12 and covers 7 lines of the original and 8 lines of the changed text. Lines that start with a space are the same in both, - means removed, + means added. A downloaded .diff file can be applied to the original file with the patch command.
How long can the texts be?
Up to 200,000 lines on each side. A few thousand lines take a moment, even on a phone. When two long texts have almost no lines in common, the tool switches to a faster method whose result is still correct but not always the shortest, and tells you so.