Menu

Diff Checker

Diff Checker: How It Works

A diff checker compares two texts and shows exactly what changed. Reading a diff well is a skill worth having: it is how code review works, how contract redlines are checked, and the fastest way to answer 'what is different about this version?'

How a diff is computed

Most tools solve the longest common subsequence problem: find the largest set of lines appearing in both texts in the same order, then mark everything else as added or removed. There is no concept of 'moved' or 'edited' — a changed line is represented as one deletion plus one addition, which is why a small edit to a long paragraph can look like a wholesale rewrite.

MarkerMeaning
- / redPresent in the original, absent in the new version
+ / greenPresent in the new version only
unchangedContext, shown to locate the change

Granularity changes what you see

LevelBest forWeakness
LineCode, configuration, structured dataProse reflows into one enormous change
WordDocuments, contracts, articlesNoisy on code
CharacterShort strings, IDs, hashesUnreadable on anything long

The most common frustration — 'it says the whole paragraph changed when I altered one word' — is a granularity mismatch. Prose written as one long line per paragraph produces a line diff that is technically correct and useless. Word-level comparison fixes it.

Whitespace

Invisible differences are the ones that waste time: trailing spaces, tabs versus spaces, and line endings. Windows uses carriage return plus line feed (\r\n) while Unix, Linux and macOS use line feed alone (\n). A file that has passed through both systems can show as entirely changed while looking identical, because every single line differs by one invisible character.

Most tools offer an option to ignore whitespace. Turn it on when comparing content and off when comparing anything where whitespace is significant — Python, YAML, Makefiles.

Reading a diff well

  1. Check the scale first. Ten changed lines is a review; a thousand needs a conversation about what happened.
  2. Separate formatting from substance. A reformat mixed with a logic change hides the logic change. Ask for them as separate commits.
  3. Look at deletions as carefully as additions. Removed error handling is invisible if you only read the green.
  4. Read the context lines. A change that looks fine in isolation may be wrong for the block it sits in.

Practical uses beyond code

This comparison runs entirely in your browser, which matters for the contract and configuration cases — both routinely contain material that should not be pasted into a server-side tool.

Frequently Asked Questions

Why does it say the whole paragraph changed when I edited one word?
Line-level comparison treats any altered line as a deletion plus an addition. If your prose is one long line per paragraph, one word changes the whole line. Switch to word-level comparison for documents.
Why do two identical-looking files show as completely different?
Almost always line endings. Windows uses carriage return plus line feed; Unix systems use line feed alone. Every line differs by one invisible character. Enable the option to ignore whitespace, or normalise the endings.
Can a diff show that text was moved?
Standard algorithms cannot — a moved block appears as a deletion in one place and an addition in another. Some specialised tools detect moves, but the common line-based algorithm has no concept of it.
Should I ignore whitespace?
When comparing prose or documents, yes. When comparing Python, YAML, Makefiles or anything where indentation carries meaning, no — the whitespace is the content.
What is a three-way diff?
A comparison of two versions against their common ancestor. It is what merge tools use to distinguish a change you made from a change someone else made, and to identify genuine conflicts rather than flagging every difference.
Is it safe to paste confidential text here?
The comparison runs entirely in your browser and nothing is transmitted. That is worth checking with any online diff tool before pasting contracts, credentials or configuration files.

Related Text Tools

Browse all Text tools →