🧰 ToolPicoAll Tools →

HomeBlog › How Do I Find What Changed Between Two Versions of a Document?

How Do I Find What Changed Between Two Versions of a Document? A Text Diff Guide

A collaborator sent back an edited contract, or you're staring at two drafts of an email and can't tell what actually changed. Here's how text diffing pinpoints every addition and deletion automatically, how the similarity percentage is worked out, and which comparison mode fits your situation.

In this guide

What a text diff actually shows you

Quick answerA text diff aligns two versions of a text using the longest common subsequence (LCS) between them, then marks anything only in the old version as removed and anything only in the new version as added. What's left unmarked is unchanged — the part both versions share.

Instead of reading two documents side by side and hoping you spot every edit, a diff tool does the alignment mathematically. It finds the longest sequence of words, lines, or characters that both texts have in common, in the same order, and treats everything outside that shared backbone as a change. That's what separates a real diff from a simple "these two strings aren't equal" check — it tells you specifically what changed and where, not just that something did.

A browser-based comparison tool that implements this with plain JavaScript can run the whole calculation client-side: paste the old text into Text A and the new one into Text B (or upload a .txt, .md, or code file for each), and the comparison updates as you type. Nothing is sent to a server, which matters if you're comparing a contract draft, source code, or anything else you'd rather not upload anywhere.

Word, line, or character mode — which one to pick

Quick answerUse line mode for source code and structured files, since edits happen line by line. Use word mode for prose, articles, and translations, where you want to see which words changed inside a sentence. Use character mode when you're hunting a single typo or a subtle change in a short string.

The three modes don't just change how the diff looks — they change what counts as "one unit" for the alignment algorithm. In line mode, an entire line is either matched, added, or removed as a block, which is exactly how source control diffs work and why it's the natural choice for code, config files, and logs. Word mode breaks a sentence into individual words, so a single swapped adjective shows up as one small change instead of the whole line turning red. Character mode goes finer still, catching a single flipped letter that word mode would otherwise report as "one word changed."

Which mode fits which situation
ModeComparesBest for
LineWhole linesSource code, config files, logs, lists
WordIndividual wordsArticles, emails, translations, contracts
CharacterIndividual charactersTypo fixes, short strings, IDs or keys

A tool with a side-by-side and an inline view lets you pair either mode with a layout: side-by-side puts Text A and Text B in two columns (removals highlighted in the left column, additions in the right), which mirrors how most people already read code reviews; inline weaves both into one flowing block, which tends to read more naturally for prose. Turning on "Ignore case," "Ignore whitespace," or "Ignore punctuation" beforehand can also strip out cosmetic differences — like re-indented code or a re-typed sentence with the same words — so the diff only flags changes that actually matter.

How the similarity ratio is calculated

Quick answerSimilarity = (2 × matched) / (2 × matched + added + removed) × 100. Two identical texts score 100%; completely different texts approach 0%. The number is calculated relative to whichever mode — line, word, or character — you're using.

The ratio is essentially a measure of overlap: how much of the combined content between the two versions is shared, versus how much was changed. Because it's based on matched units rather than raw character counts, the mode you pick changes the number — line mode measures structural overlap between files, while character mode gives the most granular reading of textual similarity.

Take a small, illustrative example: comparing "red fast car" (Text A) to "blue fast car" (Text B) in word mode. Two words match ("fast" and "car"), one word was removed ("red"), and one was added ("blue"). Plugging into the formula: (2×2) / (2×2 + 1 + 1) × 100 ≈ 66.7%. This is a made-up example to illustrate the math, not a benchmark from real documents — your own similarity score will depend entirely on the two texts you paste in.

Worked example: "red fast car" vs "blue fast car" (word mode, illustrative)
WordIn A?In B?Status
redyesremoved
blueyesadded
fastyesyesmatched
caryesyesmatched
Key fact: a high similarity ratio (say, 90%+ — again, only an illustrative threshold) is a quick, practical signal that two documents share most of their content, but it isn't a plagiarism-detection score. It only compares the exact two texts you enter; it doesn't search the web or any external database.

Reading a colored diff correctly

Quick answerGreen (usually with an "ins" or "+" mark) means content only in the new text — an addition. Red with strikethrough (usually "del" or "−") means content only in the old text — a removal. Anything left plain matched in both versions and didn't change.

Once you've run a comparison, the practical workflow is to scan for color rather than re-reading every line. In a diff with a change counter and prev/next navigation, jumping directly between changed sections is faster than scrolling through a long document looking for color by eye — useful when you're reviewing a long contract redline or a large code file where most lines are unchanged.

Before comparing, messy input can bury real changes under noise — trailing whitespace, inconsistent line order, or mixed-case headers that don't actually mean anything changed. A cleanup toolbar with options like sort lines, remove blank lines, trim whitespace, and lowercase-conversion lets you normalize both texts first, so the diff that follows reflects only meaningful edits. Once you're happy with the result, options to copy it, download it as a .txt file, or copy a shareable link make it easy to attach the diff to a code review or hand it to a colleague.

Compare two texts instantly, free

Word, line, and character-level diff with color highlighting, similarity ratio, file upload, and side-by-side or inline view — entirely in your browser.

Try the free Text Compare Tool →

Frequently asked questions

How do I compare two texts?
Paste the old text into the left box (Text A) and the new text into the right box (Text B), or upload a .txt file. Then choose word, line, or character mode. The tool aligns the two texts using the LCS algorithm, highlights added parts in green and removed parts in red, and calculates a similarity ratio. The comparison updates instantly as you type.
What is a text diff?
A diff is the process of finding and displaying the differences between two texts. It aligns the two texts based on their longest common subsequence (LCS); parts found only in the first text are marked as removed, and parts found only in the second text are marked as added. This lets you see at a glance what changed between two versions of a document, piece of code, or translation.
Is comparing text online safe?
Yes. All calculation in this tool happens entirely in your browser (client-side); your text is never sent to, or stored on, a server. This makes it safe to compare confidential text such as contracts, source code, or personal documents. Your text is only encoded into an address when you click Copy link to create a shareable link — avoid that button for sensitive content.
How is the similarity ratio calculated?
The similarity ratio is based on the number of matched (unchanged) parts. Formula: similarity = (2 x matched) / (2 x matched + added + removed) x 100. If two texts are identical, the ratio is 100%; if they are completely different, it approaches 0%. The ratio is calculated based on the mode you choose (line, word, or character).
Which mode is best for comparing code?
Line mode is best for comparing source code, since code is edited line by line and clearly shows which lines were added or removed. For finding a small typo, character mode is more useful; for seeing word-level changes within a sentence, word mode is more readable.
A note on the examples above: the "red fast car" comparison and similarity-percentage thresholds in this guide are illustrative examples used to explain the math, not measured statistics from real documents. Your own similarity ratio will depend entirely on the specific texts you compare, and this article is general technical information, not legal or editorial advice for reviewing a specific document.