Text diff
Compare two texts line by line and see exactly what was added and removed. Ignore case or whitespace, and hide unchanged lines. Runs in your browser.
Runs in your browser
What the output means
Lines are matched up by the same algorithm git diff uses, then shown in one column:
removed lines marked -, added lines marked +, unchanged lines plain. The two numbers
on the left are the line numbers in the original and in the changed version, which is what
tells you that line 40 on the left is line 37 on the right.
A modified line appears as a removal followed by an addition. Line diffs have no notion of “changed” — a line either matches or it does not.
Ignoring whitespace
Turn this on when the diff is full of lines that look identical. The usual causes are:
- Line endings. A file edited on Windows carries
\r\n; the same file from a Unix system carries\n. Every line differs, and nothing looks different on screen. - Re-indentation. A formatter run, or tabs converted to spaces, changes every line in the file while changing nothing about what it does.
- Trailing spaces, which no editor displays by default.
With the option on, lines are compared after trimming and collapsing runs of whitespace. The text shown is still exactly what you pasted.
Why the algorithm matters
Comparing two files line by line in order is easy and useless: insert one line at the top and every subsequent line is reported as changed. Finding the longest common subsequence instead — the largest set of lines that appear in both, in the same order — reports the one insertion and leaves the rest alone.
This page uses Myers’ algorithm, whose cost scales with how different the inputs are rather than how long they are, so two near-identical thousand-line files diff instantly. Where the two texts have almost nothing in common, there is no meaningful alignment to find, and the result is shown as a wholesale replacement.
Your data stays here
Both texts are compared in your browser. Nothing is uploaded — worth knowing before pasting two versions of a contract, a config file, or anything else you would not put into a stranger’s server.