What a diff shows
A diff lists the changes needed to turn one text into another. It underlies version control systems such as Git, code reviews and the "track changes" view in word processors. Using this checker you can compare two drafts of an essay, two versions of a contract clause, two configuration files or the output of two program runs, and see at once what was added and what was removed instead of reading both line by line.
The algorithm
The tool finds the longest common subsequence (LCS) of the two texts, which is the largest set of pieces appearing in the same order in both. Everything in the first text that is not part of that sequence is shown as a deletion, and everything in the second text that is not part of it is an addition. Before the main step the tool strips the shared start and end of the two texts, which speeds up the common case of a small edit in the middle of a long document.
Choosing a comparison level
- Lines: best for code, logs and lists. A line that was edited appears as one removed line and one added line.
- Words: best for prose. Only the changed words are marked, so a rewritten sentence is easy to scan.
- Characters: best for spotting small typos, differing identifiers or changes in numbers.
"Ignore case" treats upper and lower case letters as equal. "Ignore extra whitespace" collapses runs of spaces and tabs and trims each line before comparing, which is helpful when text was re-indented or re-wrapped.
Limits
The comparison is quadratic in the number of units compared, so there is a safety limit. Very long texts compared by character or word may be refused with a message; switch to line mode for large files. Line mode treats the exact characters of a line as the unit, so a single changed character causes the whole line to be marked, which is the standard behaviour of line diffs. The result is generated entirely in your browser, and your text is never uploaded.
Reading the colours
Green marks added text and red with a strikethrough marks removed text. Unchanged text is plain. The colours are supplemented by underline and strikethrough styling so that the output does not rely on colour alone.