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.

How a diff lines up two versions of a contractOn the left, the original version with five clauses; on the right, the modified version with five. Three matching clauses are connected. The term is shown as a changed line, from 12 to 24 months; the penalty as removed; and the yearly CPI price review as added.OriginalModifiedScope: IT support− Term: 12 months− Penalty: 20% of balancePayment: on the 5thJurisdiction: New YorkScope: IT support+ Term: 24 monthsPayment: on the 5th+ Price review: yearly CPIJurisdiction: New Yorkunchangedchangedremovedadded
The lines joined by solid connectors form the longest common subsequence. Only the number in the term changed, so it shows up as a changed line with the swapped word highlighted.

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

MarkerMeaningWhat to check
− (red)Removed lineWhether the removal was intended — clauses and disclaimers vanish easily.
+ (green)Added lineWhether the new text is correct and in the right place.
Highlight inside a linePartly changed lineNumbers, dates, names and negations (“not”) — tiny edits with big effects.
No markerUnchanged lineNothing; 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 York

Read 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

When comparing texts pays off

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

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