Skip to main content

← Back to blog

How to Compare Two Texts and See Exactly What Changed

You have two versions of the same thing — a document before and after edits, two config files, a colleague’s rewrite of your paragraph — and you need to know exactly what changed. Reading both side by side is slow and error-prone. A diff does it instantly.

What a diff actually does

A diff algorithm finds the smallest set of additions and deletions that turns one text into the other, then shows them in color: green for added, red for removed, plain for unchanged. It’s the same technology behind “track changes” and every code review you’ve ever seen.

Line diff vs word diff

There are two useful granularities:

  • Line diff compares whole lines. Perfect for code, config files, CSV and lists, where a “change” usually means a whole line was added, removed or replaced.
  • Word diff compares word by word. Perfect for prose, where you want to see that only one word in a sentence changed rather than the whole line lighting up red-and-green.

Start with line diff; switch to word diff when a line shows as changed but you can’t spot what’s different.

Reading the result

  • A red line followed by a green line = that line was edited (removed, then re-added in its new form).
  • A lone green line = added.
  • A lone red line = deleted.
  • The summary (e.g. +3 −1) tells you the scale of the change at a glance.

Why compare in the browser

Diffs often involve sensitive material — contracts, credentials in a config file, unreleased copy. An online tool that uploads your text is a needless risk. The text diff tool compares entirely in your browser: neither version leaves your device.

A third granularity: character diff

For very short, dense strings, even a word diff is too coarse. A character diff compares letter by letter, which is what you want when a single character is the whole story — a transposed digit in an order number, one wrong character in a hash or API key, or a typo buried inside a long token. Where a word diff marks the entire token as changed, a character diff points straight at the character that differs.

Rule of thumb: line diff for files and lists, word diff for prose, character diff for codes and identifiers.

When you’ll reach for a diff

  • Reviewing an edit — see exactly what a colleague, an editor, or an AI rewrite changed in your draft.
  • Comparing versions — a contract, a set of terms, or a config file before and after a change.
  • Verifying a copy — confirm two exports, two translations, or two lists really match, character for character.
  • Chasing a near-duplicate — two blocks that look identical but produce different results.

Common misunderstandings

  • A diff doesn’t track “moved” text. Cut a paragraph and paste it lower down, and most tools show one deletion plus one addition, not a move.
  • A whole highlighted line doesn’t mean everything changed. In line mode, changing one word flags the entire line — drop to word or character diff to see the real edit.
  • Invisible characters still count. Two lines that look the same can differ by a trailing space, a tab, or a line ending; that’s a genuine difference, not a glitch — which is exactly what the tidy-up in the guide to removing line breaks and duplicate lines prevents.

Tip: normalize first for a cleaner diff

If two files differ only in trailing spaces, tabs or line endings, the diff will be noisy. Run both through the text cleaner first — trim lines and standardize spacing — and the real differences stand out.