How a diff lines up two versions, how to read the red and green markers, and the whitespace traps to watch for.
You have two versions of the same thing — a contract before and after edits, last week's config and today's, two near-identical error logs — and you need to know exactly what changed. Reading both side by side and hoping to spot the difference is slow and unreliable. A diff does it precisely: it lines up the two versions and marks every line that was added, removed, or changed. This article explains how diffing works and how to read its output with confidence.
A diff tool compares two pieces of text line by line and finds the smallest set of changes that turns the first into the second. It does not just check “are these identical?” — it figures out which lines stayed the same, which were inserted, and which were deleted, even when large blocks have moved or new paragraphs were dropped in the middle. The result is usually shown in one of two layouts: side-by-side, with the old version on the left and the new on the right, or inline, with removals and additions stacked and colour-coded.
Most diffs use a consistent visual language:
-.+.That last point is the key insight. A diff has no separate “modified” category — every edit is expressed as deleting the old and inserting the new. Once you see it that way, even a dense diff becomes easy to scan.
The default unit of comparison is the line, which is perfect for code and config files where each line is meaningful. But for prose, a single changed word turns the whole paragraph (if it is one long line) red-then-green, which is hard to read. That is where a word-level or character-level diff helps: it highlights just the few words that actually changed inside an otherwise unchanged sentence. When you compare paragraphs of writing, prefer a tool that can show word-level differences.
A few non-obvious factors change what a diff reports:
A diff answers one question precisely: what changed between version A and version B. It expresses every edit as a removal plus an addition, lines them up so the unchanged parts give context, and lets you verify changes instead of trusting your memory. Whether you are reviewing a contract, debugging a config, or checking an edit, comparing the two versions in a diff tool is faster and far more reliable than reading them side by side by eye.