Compare Two Texts: 6 Easy Ways to Spot Every Change
Somebody sent back a revised version and said only that a few things changed. A few means nothing until you can compare two texts line by line and see them. This guide shows six real jobs, from contract review to config files, and which setting to pick for each one.
How to compare two texts: what a diff really does
A diff does not read for meaning. It looks for the longest set of lines that both texts share in the same order, then marks everything else as a removal or an addition. Computer scientists call that the longest common subsequence problem, and the Unix diff command from the early 1970s was built on it. To compare two texts well, you need to know that.
Take two lines that differ by one word. Text A says jumps over the dog and text B says leaps over the dog. At line level that is one removed line and one added line. Character level then runs the same matching inside the pair, so only jumps and leaps get highlighted.
Same change when you compare two texts, shown as a diff
The quick fox
- jumps over the dog
+ leaps over the dogSettings that change the result
Four options decide what the tool treats as different when you compare two texts. Choose them before you read the output, because the wrong setting makes a harmless edit look like a rewrite.
| Setting | What it does | Use it when |
|---|---|---|
| Line level | Marks whole lines as added or removed | Lists, code, contracts with one clause per line |
| Char level | Highlights changed characters inside a line | One word changed inside a long paragraph |
| Ignore case | Treats upper and lower case as equal | Text was reformatted to title or capital letters |
| Ignore extra whitespace | Collapses runs of spaces and tabs, trims the line | Code pasted from another editor, or double spaces |
| Unified view | One column, changes inline in order | Short texts, or pasting into a review comment |
| Side by side view | Two columns with filler rows to stay aligned | Long documents you want to read in parallel |
Line level treats each line as one unit, so an edited line is a removal of the old version plus an addition of the new one. Switch to character level to see just the changed characters.
Six reasons to run a diff, by role
Pick the tab that matches your work. Each one names a typical task, the setting to try first and what to look for in the result. Each tab shows a different reason to compare two texts.
Task: you edited a 1,200 word article and the author returned a version with unmarked changes. Paste your copy in A, theirs in B and use side by side with character level on.
Look for small swaps, such as a figure changed from 14 percent to 41 percent, that a quick read would miss. Turn on ignore extra whitespace first, because word processors often add double spaces that make every line look changed.
Task: two copies of a config file behave differently and nobody remembers why. Use line level with unified view, and leave case sensitivity on, since keys are usually case sensitive. Developers compare two texts all day without noticing.
Example: A has port, debug true and host. B has port, debug false, host and a new timeout line. The result is 2 unchanged lines, 1 removed and 2 added, which is the whole difference in five lines. For API payloads, the API Response Diff Checker compares structure instead of plain lines.
Task: the other party returned a draft marked as minor edits. Put the last signed version in A and the new draft in B, with character level on. Do not ignore case for names or defined terms, as Company and company can mean different things in a contract.
Check numbers, dates and negations first. A single word such as not, shall or may changes obligations, and character level makes that word glow.
Task: compare a draft with a revised essay, or check two submissions for shared passages. Line level works when each sentence sits on its own line, so add line breaks before you paste.
For revision work, the added and removed counts show how much was rewritten. A draft with 40 added and 38 removed lines changed far more than one with 3 and 2. Teachers can compare two texts to judge effort.
Task: a source document was updated after you began translating. Compare the old source with the new source, and translate only the lines marked added or changed.
On a 300 line document where 22 lines changed, that is about 7 percent of the work instead of a full retranslation.
Task: a landing page lost conversions after an update and you want to know what copy changed. Paste the earlier text and the current text, then read the removed lines first.
Headlines, prices and button labels are the usual suspects. Compare also works for two meta descriptions, two ad variants or two product feed exports.
A worked example, step by step
Here is a short example you can paste into the tool. It is a price list, the kind of text where one number matters more than a hundred words. Use it to compare two texts yourself.
Text A (original)
Basic plan: 9 dollars per month
Standard plan: 19 dollars per month
Pro plan: 39 dollars per month
Support: email onlyText B (revised)
Basic plan: 9 dollars per month
Standard plan: 24 dollars per month
Pro plan: 39 dollars per month
Support: email and chat
Annual billing: 2 months free| Line | Status | Why |
|---|---|---|
| Basic plan: 9 dollars per month | Unchanged | Identical in both |
| Standard plan: 19 dollars per month | Removed | Only in A |
| Standard plan: 24 dollars per month | Added | Only in B |
| Pro plan: 39 dollars per month | Unchanged | Identical in both |
| Support: email only | Removed | Only in A |
| Support: email and chat | Added | Only in B |
| Annual billing: 2 months free | Added | Only in B |
The totals are 2 unchanged, 2 removed and 3 added. Character level would then narrow the Standard line to the digits 19 and 24, and the Support line to the words only and and chat. That is the fastest way to confirm that a price moved by 5 dollars and nothing else on that line did. That is a clean way to compare two texts.
A diff compares lines. If a whole article sits on one line, any edit marks the entire article as changed. Break the text into one sentence per line, then compare, and the output gets far easier to read.
Paste both versions, pick line or character level, and read the changes in unified or side by side view. You can copy the result as a plain patch to share. You can compare two texts as often as you like.
Open the Text Diff ToolLimits on input size
This tool builds a full table to find the shared lines. Its work grows with the number of lines in A times the number in B. That is fine for articles, contracts and config files, and slower for huge files. Keep that in mind when you compare two texts of book length.
| Lines in A | Lines in B | Table cells |
|---|---|---|
| 200 | 200 | 40,000 |
| 1,000 | 1,000 | 1,000,000 |
| 5,000 | 5,000 | 25,000,000 |
Production tools such as Git use the Myers algorithm instead, published in 1986, which does far less work when two files are mostly the same. For comparing whole code repositories, use Git. For two documents of a few thousand lines or less, a browser diff is plenty.
A good fit for a browser tool
- Drafts, contracts, essays and web copy
- Config files and short scripts
- Two API payloads pasted as text
- Anything private you would rather not upload
Better with other tools
- Whole repositories with history, use Git
- Word processor files with tracked changes
- Binary files and images
- Documents of tens of thousands of lines
Why a comparison of two texts can look wrong
| What you see | Likely cause | Fix |
|---|---|---|
| Every line marked changed | Different line endings or trailing spaces | Turn on ignore extra whitespace |
| Capitalisation changes everywhere | Text was reformatted | Turn on ignore case |
| One huge removed block and one huge added block | The text sits on one long line | Add line breaks, then compare again |
| A moved paragraph shows as removed and added | A diff has no concept of moving | Read the pair as one move |
| Changes look tiny but you expected more | Character level hides nothing, but the edit is small | Check the added and removed counts |
Before you compare two texts that are long lists, tidy them first. Remove repeats with the Duplicate Line Remover and put both lists in the same order with the Text Sorter. Two sorted lists show only the true differences.
Frequently asked questions
How do I compare two texts online for free?
To compare two texts online, paste the first in box A and the second in box B, then press compare. Added lines, removed lines and unchanged lines are marked, and no account is needed.
What is the difference between line level and character level when I compare two texts?
Line level marks whole lines as added or removed. Character level also highlights the exact characters that changed inside a modified line, which helps with small edits in long paragraphs.
Is it safe to compare two texts that are confidential documents in a browser tool?
The comparison runs in your browser with JavaScript, and neither text is sent to a server. Even so, follow your own organisation rules for sensitive material.
Why does my diff say every line changed when I compare two texts?
Usually the lines differ in invisible ways, such as trailing spaces, tabs or line endings. Turn on ignore extra whitespace and compare again.
Can I compare two texts that are code files?
Yes. Any plain text works, including code, config files and JSON. For whole projects with history, a version control tool like Git is a better fit.
What does the plus and minus mean in a diff?
A plus prefix marks a line that exists only in the new text, a minus prefix marks a line that exists only in the old text, and two spaces mark an unchanged line.
Sources: Wikipedia: diff, the Unix utility and its longest common subsequence basis
