How to Compare Two Texts and Find the Differences Line by Line

A colleague sends you the second version of a contract and says the changes are "minor". You read the six pages once, then again, and still cannot be sure you have not missed a sentence changed by a single word. The human eye is particularly poor at this task, because it reads what it expects to see, not what is written. That is where a text comparison tool earns its place: it does precisely what we cannot do efficiently.
How the comparison works
The tool does not hunt for random "differences". It solves a specific problem: what is the smallest number of lines to delete and add to turn the first version into the second? It finds the longest sequence of lines the two texts share and treats everything else as a change. The output has three kinds of line:
- Added: a line present only in the second text.
- Removed: a line present only in the first text.
- Unchanged: a line present in both, in the same place.
A line in which a single character was edited shows up as a removed line followed by an added one, because the comparison works at the level of lines. That is normal, and it means you read those two adjacent lines against each other to see exactly what changed.
How to use it
- Paste the old version into the first side and the new version into the second.
- Pick the options you want: ignore whitespace, or ignore letter case.
- Read the result: added and removed lines are coloured, and what stayed the same is shown quietly.
- Copy what you need, or edit your text and compare again.
All of this is in Sahel's text diff checker, which runs in your browser so your text never leaves your device — important when you are comparing a contract or a private message.
When to ignore whitespace and case
The two options change what the tool counts as a "difference", and it helps to know when to use them:
- Ignore whitespace: useful when a file was reformatted and indentation or spacing changed without changing the meaning. Without it, hundreds of lines look changed that you do not care about. But do not enable it for languages where indentation carries meaning, since you could hide a real change.
- Ignore case: useful when comparing text that does not distinguish capitals from lower case, such as email addresses. Do not enable it for code and variable names, where a capital in place of a lower-case letter can be a genuine bug.
The rule: start with a strict comparison and no ignoring. If you drown in cosmetic noise, turn on the relevant option. That way you never lose a real difference by accident.
A realistic scenario
A purchasing manager receives a renewed contract from a supplier and wants to know, before signing, what changed from last year's. She pastes both versions into the tool and turns on ignore-whitespace because the supplier changed its formatting template. Instead of dozens of differences she sees only three real ones: an altered payment term, a new line about late-payment penalties, and the deletion of a clause that had made the supplier bear shipping costs. She would never have found the deleted clause by reading alone, because an absence is much harder to notice than a presence. For anything substantive she should still consult a legal adviser — the tool shows where the changes are, it does not interpret their effect.
And if the two versions are JSON files, format both first with the JSON formatter so they are written the same way, then compare them, and differences that come only from spacing will not appear.
Frequently asked questions
Is the text I paste uploaded to a server?
No. The whole comparison runs in the browser and neither text is sent anywhere.
Is there a size limit?
Yes, five thousand lines per side. The cost of comparison grows quickly with length, and past that point the page would freeze rather than finish. For larger files use a dedicated command-line tool.
Why does a line where I changed one character appear as a removal plus an addition?
Because the comparison works on lines, not characters. The edited line no longer matches its original, so the original appears removed and the new one added, side by side, for you to compare yourself.
Does it detect a paragraph moved from one place to another?
It does not treat it as a move. You see the paragraph removed from its first position and added at the second. That is the usual behaviour of this kind of tool.
Does it work on Arabic text?
Yes. The comparison treats lines as whole strings in any language, and Arabic is displayed in the correct direction. Just watch for diacritics: a word with vowel marks and the same word without them are counted as different.
Related articles

Markdown Previewer: Write in a Simple Syntax, See the Result Instantly, and Copy Clean, Safe HTML

Lorem Ipsum Generator: Why Designers Use Placeholder Text and How to Use It Properly

How to Decode a JWT and Read Its Claims: What Is Inside, and What the Signature Does Not Tell You
