Compare two texts (diff)

Paste the original on the left and the changed version on the right. Added lines show in green, removed lines in red.

How the comparison works

The tool finds the longest common subsequence (LCS) of lines: the largest set of lines that appear in both texts in the same order. Everything in the original that is not part of it is marked removed (−), and everything in the new text that is not part of it is marked added (+). This is the same idea behind the classic Unix diff.

L[i][j] = a[i] = b[j] ? L[i+1][j+1] + 1 : max(L[i+1][j], L[i][j+1])

Example

Original apples, bananas, cherries vs changed apples, blueberries, cherries: "bananas" is removed, "blueberries" is added, the other two lines are unchanged.

A changed line appears as one removal plus one addition. Whitespace counts, so a trailing space makes two lines different; run both texts through Remove extra spaces first if that matters.

Frequently asked questions

Is there a size limit?
The comparison uses a table of lines × lines, so texts up to about 2,000 lines each compare instantly. Very large files are better compared with a desktop diff tool.
Does it compare words or characters?
It compares whole lines. Put each sentence on its own line if you want a finer comparison.