How to compare two texts and spot every difference
Learn how text comparison (diff) works, how to read added, removed and changed lines, and when to ignore whitespace or letter case.
You sent a contract out for review and it came back with “a few tweaks”. Or a teammate edited the website copy and can't remember what they touched. Rereading both versions sentence by sentence is slow and unreliable: your eyes skip exactly the comma or number that changed.
A text comparison does that checking for you: it marks what was taken out, what was put in and, inside each changed line, the exact word that was swapped. If you want to follow along with your own texts, keep the text compare tool open in another tab.
What is a diff?
A diff is the result of comparing two versions of a text: the smallest list of lines you need to remove and add to turn the original into the modified version. Anything not on that list is the same in both. The idea comes from programming tools, but it works for any kind of text — contracts, essays, lists or configuration files.
“Smallest” matters. There are endless ways to describe how one text became another — at the extreme, “delete everything and type it all again”. A good diff looks for the shortest explanation, which is also the easiest one to review.
How a comparison finds the differences
Most tools compare line by line. First, the algorithm looks for the largest set of lines that appear in both versions in the same order, though not necessarily next to each other — the longest common subsequence (LCS). Those lines are marked as unchanged. Whatever is left over in the original was removed; whatever is left over in the modified version was added.
Doing this efficiently isn't trivial. The most widely used algorithm was published by Eugene Myers in 1986; it underpins GNU diff and is Git's default diff algorithm. The comparison tool on this site is built on the same approach.
There's one extra, very handy step: when a removed line and an added line sit in the same spot and look alike, the tool treats them as a changed line and highlights only the words that differ. That's the term clause in the figure: instead of comparing two whole lines in your head, you see at once that “12” became “24”.
What to check for each marker
| Marker | Meaning | What to check |
|---|---|---|
| − (red) | Removed line | Whether the removal was intended — clauses and disclaimers vanish easily. |
| + (green) | Added line | Whether the new text is correct and in the right place. |
| Highlight inside a line | Partly changed line | Numbers, dates, names and negations (“not”) — tiny edits with big effects. |
| No marker | Unchanged line | Nothing; it's there for context. |
A reading order that works well for documents: start with the removals, because that's where warranties, penalties and caveats disappear without anyone mentioning it. Then move to the changed lines, checking numbers and negations first. Leave the additions for last — they're usually the changes you were already expecting. In the figure's example, that order would show you straight away that the termination penalty is gone.
What is the unified diff format?
Unified diff is the standard plain-text format for recording changes, used by diff -u, Git and code review tools. Lines starting with - were removed, lines starting with + were added, and lines starting with a space are context. The @@ header says where the block starts in each version.
@@ -1,5 +1,5 @@
Scope: IT support
-Term: 12 months
-Penalty: 20% of balance
+Term: 24 months
Payment: on the 5th
+Price review: yearly CPI
Jurisdiction: New YorkRead it like this: the block covers 5 lines starting at line 1 in the original (-1,5) and 5 lines starting at line 1 in the modified text (+1,5). Notice that in unified format a changed line becomes a pair: the old version with - and the new one with +. That's the text the tool's copy button produces, and anyone who has reviewed code will recognize it.
When to ignore whitespace and letter case
- Ignore whitespace: use it when the text went through an editor that changed the formatting — double spaces, indentation, tabs. Without it, those lines show up as changed and bury the edits that matter.
- Ignore case: useful for name lists, keywords or data exported from different systems, where “NEW YORK” and “New York” mean the same thing.
- Don't ignore them for source code in case- or indentation-sensitive languages (such as Python and YAML), or for passwords, keys and identifiers: there, one space or capital letter changes the meaning.
When comparing texts pays off
- Contracts and proposals: make sure only the agreed points changed before you sign.
- Document versions: see exactly what an editor changed in an article, report or paper.
- Code and config snippets: compare an
.envfile, a JSON payload or a SQL block between two environments. - Republished text: check whether a copied passage is identical to the source or was quietly edited.
If you also need to know whether the new version got longer or shorter, the word counter shows the word and character count of each one — and the word counter guide explains when a limit is measured in characters instead of words.
Limitations worth knowing
- Moved blocks show up as removed in one place and added in another — a plain line-by-line diff doesn't know it's the same passage. (Git's
--color-movedoption exists to highlight those cases.) - Long paragraphs count as a single line. If the text has no line breaks, a small edit flags the whole paragraph (with the changed words highlighted).
- Formatting such as bold, colors and tables from Word or PDF is lost when you copy; the comparison is plain text only.
Compare your texts now
In the text compare tool, paste the original and the modified version and look at the removed-lines count first: if it's higher than you expected, that's where the surprise is. Then follow the reading order above and, if you need to send the result to someone, copy the unified diff.
Frequently asked questions
Can a text compare tool detect plagiarism?
No. It only compares the two texts you paste and shows what changed between them. Plagiarism checkers search large databases of published work for similar passages. Still, a diff is a quick way to confirm whether a suspicious passage is a word-for-word copy of a source you already have.
Can I compare Word or PDF files?
Yes — copy the text from each file and paste it into the two fields; bold, colors and tables are left out. PDFs often break lines in different places, and ignoring whitespace doesn't fix that. Before pasting, join the lines of each paragraph or put one sentence per line in both versions.
Why is a whole paragraph marked as changed?
Because the comparison works line by line, and a paragraph without line breaks is a single line. If any word in it changes, the whole line is flagged. The tool highlights the changed words inside it, but splitting long paragraphs into one sentence per line makes the result much easier to scan.
Don't Word and Google Docs already compare documents?
They do: in Word, use Review › Compare; in Google Docs, Tools › Compare documents. Both keep formatting but need files in their own formats. An online diff is faster for snippets pasted from anywhere — emails, code, web pages — and doesn't require an account.
What does the similarity percentage mean?
It estimates how much content the two versions share, counting unchanged lines and the preserved part of changed lines. 100% means the texts are identical under the options you picked. Treat it as a quick indicator, not an exact measure of how much the text was rewritten.
References
- Eugene W. Myers, “An O(ND) Difference Algorithm and Its Variations”, Algorithmica, 1986.
- GNU Diffutils manual, Unified Format.
- Git documentation, git-diff.