Compare two texts side by side, with the changed words marked rather than the whole line and syntax highlighting for sixteen languages. Nothing is uploaded.
How it works
Put the original text in the left pane and the changed text in the right, then press Diff. Nothing is compared until you ask, and typing in either pane afterwards clears the marks, since they describe text that is no longer there. Swap exchanges the two documents as an ordinary edit, so Ctrl+Z undoes it.
The comparison runs twice. The first pass is Myers' algorithm over whole lines, the algorithm GNU diff is built on and Git's default: it finds the fewest lines to delete and insert, tints removed lines red on the left and added lines green on the right, and counts both. The second pass pairs the first removed line of each block of changes with its first added line, the second with the second, and compares each pair again by words, runs of whitespace and single punctuation marks. That is what puts the mark on 30 and 45 rather than on the whole line.
Word marks are left off a pair with less than 35 per cent of its characters in common, because the pairing was then only by position, and off lines longer than 2,000 characters. Two documents that would need more than 2,000 lines deleted or inserted to align are not aligned at all: everything between the matching first and last lines is marked, and the summary says so.
Both documents and the language chosen for colouring are kept in the page's address, so a copied link reopens the same comparison with its marks.
Examples
A changed setting and a new one
timeout = 30
retries = 3
host = "db.internal"
timeout = 45
retries = 3
host = "db.example.com"
log = "debug"
2 lines removed, 3 lines added
Original, line 1: 30
Original, line 3: internal
Changed, line 1: 45
Changed, line 3: example.com
Changed, line 4: the whole line, no words marked
The new log line has no removed line opposite it, so it is tinted green with no words picked out.
An argument added to a function
function total(items) {
let sum = 0;
for (const item of items) sum += item.price;
return sum;
}
function total(items, tax) {
let sum = 0;
for (const item of items) sum += item.price * item.qty;
return sum * (1 + tax);
}
3 lines removed, 3 lines added
Changed, line 1: ", tax"
Changed, line 3: " * item.qty"
Changed, line 4: " * (1 + tax)"
The three lines on the left are tinted but carry no word marks, because nothing was taken out of them: every change is an insertion.
A moved line
moved
a
b
c
a
b
c
moved
Reported as “1 line removed, 1 line added”: moved is marked on line 1 of the original and line 4 of the changed text, and the three lines between are left alone. A line diff has no notion of a move, only of a deletion in one place and an insertion in another.
Common problems
Two files that differ only in line endings
The editors read \r\n, \r and \n all as the end of a line, so a Windows file and its Unix copy come out as “The documents are identical”. A byte-level comparison still sees them differ; open both in the hex viewer and look for 0d 0a against 0a.
Changes in whitespace you cannot see
There is no option to ignore whitespace. value against value followed by three spaces is a changed line with the three spaces tinted, and a tab replaced by four spaces marks both. Re-indenting a file marks every line it touched.
A changed line with no word marks
Lines are paired by position within a block of changes, so a line inserted just above an edited one throws the pairing off. With old line here changed to old line there and a new line added above it, the old line is paired with the inserted one, which has too little in common to mark, and old line there is left with no partner, so neither change is pointed at within its line.
Minified files
A minified file is one very long line, so it is marked as a whole and never word by word. Pretty-print both copies first, for JSON with the JSON formatter, and the changes land on lines of their own.
Frequently asked questions
Why don't the marks update as I type?
They describe the two documents as they were when Diff was pressed. Any edit clears them on both sides, rather than leaving marks that point at text which has since moved, and pressing Diff again compares what is there now.
Can it ignore whitespace or letter case?
No. Every character counts, including trailing spaces and the difference between a tab and spaces, which are tinted like any other change. Normalise both texts first if those differences are noise to you.
Does the language setting change the comparison?
No. It only adds syntax colouring to both panes. The comparison is the same text-based line and word diff in every language.
How large can the documents be?
There is no fixed size. What is capped is the work: if aligning them would take more than 2,000 lines deleted or inserted, the page marks the whole differing middle instead, and lines over 2,000 characters get no word marks. Long files with a few changes are compared in full.