Text Compare: Online Diff Checker
Compare two texts or files and see every difference by line, word or character. Compare JSON with sorted keys, then save a .diff patch or HTML report.
Paste or type text in both boxes, open or drop two files, or press Load example, to see the differences here.
How to compare two texts
Paste the original text on the left and the changed text on the right, or open or drop a file on either side. Any plain-text file works: .txt, .csv, .json, .xml, .log, source code and so on. The differences appear as you type. Removed text has a red background and is struck through; added text has a green background and is underlined, and in line mode each changed line also gets a minus or plus sign, so nothing depends on colour. Invisible characters that often cause puzzling differences, such as a zero-width space, a byte order mark or a right-to-left override, are shown as labels.
Line, word or character?
| Compare by | Best for | What is highlighted |
|---|---|---|
| Line | Code, lists, CSV, config files | Whole lines, with the changed words inside a changed line |
| Word | Prose, contracts, articles | Individual words and punctuation, in running text |
| Character | Short strings, IDs, typos | Single characters |
Side by side shows the two versions in columns; Inline merges them into one column, which reads better on a phone. Hide unchanged lines folds identical stretches and keeps three lines of context around each change.
How the comparison works
The tool uses Eugene Myers’ O(ND) difference algorithm (1986), the method behind GNU diff and Git’s default diff. It finds the fewest insertions and deletions that turn one text into the other. Lines found on only one side are set aside first, as GNU diff does, and the work runs in a background thread, so texts of many thousands of lines stay responsive. In word and character mode, changed blocks are compared again word by word or character by character; an emoji or an accented letter counts as one character.
Within each block of changes, removed lines are paired with added lines in order. Each pair is one changed line and the rest are added or removed, so three lines replaced by five show as 3 changed and 2 added.
Ignore options
- Ignore whitespace treats any run of spaces or tabs as one space and ignores spaces at the ends of lines. Line breaks still count.
- Ignore case compares as if everything were lower case.
- Ignore line endings, on by default, treats Windows (CRLF), Unix (LF) and old Mac (CR) line breaks as equal. Turn it off to find them: each carriage return is then shown as a CR label. Under an opened file you can see its encoding and line-ending style.
The options change only the comparison, never your text.
Comparing JSON
Compare as JSON reads both sides as JSON and lays them out the same way, two spaces per level, so only real changes remain. Sort keys puts object keys in alphabetical order, since their order carries no meaning; arrays keep their order. Numbers are compared by value (1.0 equals 1), long integers digit by digit, and escaped characters are decoded first. Comments and trailing commas, allowed in files such as tsconfig.json, are accepted and dropped. If a key appears twice, the last value counts, as in JavaScript. Invalid JSON is reported with its line and column, and the texts are then compared as plain text.
Saving the result
Download .diff saves a unified diff, the format of diff -u and
git diff, with three lines of context. It is made from the exact texts,
even with an ignore option on, and keeps each file’s line endings, so
patch original.txt < text-compare.diff turns the original into the changed
file. In JSON mode it compares the formatted JSON instead. When texts differ
almost everywhere, the search for the smallest patch stops after a few
seconds and the rest is written as whole blocks, which still apply.
Download .html saves the comparison as shown, with its numbers, as one
self-contained page that opens in any browser.
Frequently asked questions
Is my text uploaded anywhere?
No. Both texts are compared in your browser, in a background thread on your own device. Opened files are read locally, and nothing is sent to a server or stored.
Why is a line I edited shown as removed and added?
A diff describes changes as removals and additions. When a removed line and an added line sit in the same place they are paired as a changed line, and the words that differ inside it are highlighted more strongly.
Do Windows and Unix line endings count as differences?
Not by default. With Ignore line endings on, CRLF, LF and CR line breaks compare as equal. Turn it off to see the lines whose endings differ, with each carriage return shown as a CR label.
Can it compare JSON whose keys are in a different order?
Yes. Turn on Compare as JSON and keep Sort keys on. Both sides are parsed, their keys sorted and the JSON laid out identically, so only differences in values remain.
How large can the texts be?
Several thousand lines compare almost instantly on a typical computer. Very large texts that differ almost everywhere take longer, but the page stays usable while the comparison runs.