How to use it
- Paste the original text on the left and the changed text on the right, or open a file on each side.
- Read the result below: removed lines are red, added lines green, and the changed words are highlighted.
- Step through a long text with “Next change” and “Previous change”; choose side by side or inline.
- Turn on the options if white space, case, blank lines or Windows line ends should not count.
- Download the changes as a .patch file if you need them for patch or git apply.
Rules and limits
How the texts are compared
- Line by line with Myers’ algorithm, as GNU diff does it: the fewest removed and added lines that turn the original into the changed text.
- In a changed block, removed and added lines are paired in order; inside a pair the changed words or characters are highlighted (a letter with its accents counts as one character). Pairs with less than a quarter in common are marked as whole lines.
- Counts, as in diff and git: a changed line counts as one removed (−) and one added (+) line; a change is a run of removed and added lines next to each other.
- Options: white space changes are ignored as
diff -bdoes (runs of spaces and tabs count as one, white space at line ends does not count); case asdiff -i; blank lines asdiff -B(changes made only of empty lines do not count; with white space changes ignored, lines of only spaces count as empty too); with CRLF as LF, a carriage return before the line break is ignored. Where two pairings of the lines are equally short, the page may choose another one than diff and so leave out a different blank change. - A missing line break at the end of a text counts as a change, as in diff, except when white space changes are ignored.
The .patch file
- A unified diff (
diff -u) with 3 lines of context, the headers---and+++, and\ No newline at end of filewhere a text does not end with a line break. - Without the ignore options, GNU patch applies it to the original and gives exactly the changed text, byte for byte; with an option on, the ignored differences are left out of it.
Limits
- Each text up to 20 MB of Latin text (20 million characters) and 1,000,000 lines.
- Tested in Chrome on a laptop, from opening the files to the result: two files of 1,000,000 lines (about 17 MB each) with every hundredth line changed in 5.7 s; two files of 200,000 lines that differ in every line in 1.6 s; 40,000 shuffled lines, compared the faster way after 5 s, in 7.8 s.
- The exact comparison runs for at most 5 seconds; texts that differ almost everywhere then get a faster comparison, which can mark more lines than needed, and the page says so.
- Files are read as UTF-8 (with or without a byte order mark) or UTF-16; a file that is not valid UTF-8 is read as Windows-1251 or Windows-1252, and the page names it.
Questions and answers
Why is every line marked as changed?
Usually the line ends differ: one text was saved on Windows (CRLF), the other on macOS or Linux (LF). The page notices it and offers to treat CRLF as LF. Tabs against spaces are the other usual cause; “Ignore changes in white space” hides them.
How do I apply the .patch file?
In a terminal: patch original.txt changes.patch, or git apply changes.patch inside a git repository. For files with Windows line ends, run patch with --binary, so that it keeps them.
Does it find the same changes as diff on Linux?
It marks as few lines as possible, like diff --minimal: the tests check its counts against GNU diff and apply its .patch files with GNU patch. The lines it pairs can differ where several equally short answers exist.
Are my texts uploaded?
No. The comparison runs in your browser, and the page cannot send your texts anywhere, so you can compare contracts, code or private notes.