How to use it
Paste the older text into Before and the newer one into After. The comparison runs in your browser as you type, so nothing is uploaded.
- Choose the unit: Lines for code and configs, Words for prose, Characters for short strings.
- Tick Ignore whitespace to stop indentation, trailing spaces and line endings from counting, and Ignore case to match
Hellowithhello.
The line above the result says The two texts match. or counts the changes, like 3 lines added · 2 lines removed. In Lines, a table pairs each line with the line it became and highlights the changed words inside each pair, deletions in red and insertions in green. Under it, Unified diff holds the same changes as a patch, with Copy. Words and Characters show one running text with the changed pieces highlighted.
Examples
A config change, with Lines:
host = localhost
port = 8080
debug = true
workers = 4
host = localhost
port = 9090
debug = false
workers = 4
timeout = 30
The status reads 3 lines added · 2 lines removed, and the table highlights only 8080/9090 and true/false inside lines 2 and 3. The unified diff:
--- before
+++ after
@@ -1,4 +1,5 @@
host = localhost
-port = 8080
-debug = true
+port = 9090
+debug = false
workers = 4
+timeout = 30
An edited line is one deletion plus one insertion, so two edits and one new line make 3 added and 2 removed.
One sentence, with Words and then Characters:
The quick brown fox jumps over the lazy dog.
The quick red fox leaps over the lazy dog!
Words gives 3 words added · 3 words removed: brown, jumps and dog. become red, leaps and dog!, since a word is any run of non-space characters. Characters gives 6 characters added · 8 characters removed, because it keeps the r of brown and the ps of jumps.
A file with Windows (CRLF) line endings against the same file with LF, with Lines (endings written as escapes):
name: api\r\nport: 8080\r\n
name: api\nport: 8080\n
Every line differs, and the table shows each carriage return as a highlighted \r at the end of its line. With Ignore whitespace, it’s The two texts match.
Two 3,000-line files with no line in common give The two texts differ in more than 5,000 lines, which is past what this page compares. Compare a smaller stretch. From Characters or Words, the message also suggests a coarser mode.
Good to know
- The diff is the shortest one. It uses Myers’ O(ND) difference algorithm (1986), the default in
git diff, so it has the fewest added and removed units. Shortest isn’t always natural: a line moved from the top to the bottom shows as a deletion at the top and an insertion at the bottom. - The unified diff is the format of
diff -uandgit diff. Each hunk starts with@@ -start,count +start,count @@, the count left out when it’s 1, then lines marked with a space for context,-for removed and+for added. There are 3 lines of context, and changes 6 or fewer unchanged lines apart share a hunk. The headers saybeforeandafter, not file names, so name the file to apply it:patch config.ini < changes.diff. - A missing final newline is a real difference. POSIX defines a line as ending in a newline, so
a\nbanda\nb\ndiffer even with Ignore whitespace. The unified diff marks it\ No newline at end of fileand the tableno newline. - Ignore whitespace works per unit. In Lines, runs of whitespace collapse to one space and the ends are trimmed, so
a bmatchesa bbut notab. In Words, any run of whitespace matches any other; in Characters, a tab matches a space. - Characters are Unicode code points, so a flag emoji counts as two.
- Limits: each text up to 50,000 characters, and a comparison stops past 5,000 changed lines or 20,000 changed words or characters. The table shows the first 2,000 lines; the unified diff keeps every change.
Questions
How do I compare two texts for differences?
Paste one into Before and the other into After, and the changes are highlighted as you type. Use Lines for code and Words for prose, where a paragraph is one long line.
How do I compare two files in the terminal?
Run diff -u old.txt new.txt for a unified diff. git diff --no-index old.txt new.txt works on any two files, in a repository or not, and --word-diff added to it marks changed words instead of lines.
Why does every line show as changed?
Usually the line endings differ: one file uses CRLF (Windows) and the other LF. Re-indenting, such as tabs to spaces, does the same. Tick Ignore whitespace to see the real changes.