GoToolsOnline Blog How-To All Tools

How to Compare Two Files or Texts (Diff Explained)

How a diff lines up two versions, how to read the red and green markers, and the whitespace traps to watch for.

By Ben Praveen J · June 2, 2026

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.

What a diff is comparing

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.

Reading the markers

Most diffs use a consistent visual language:

  • Unchanged lines appear in both columns (or plain, with no colour) to give you context.
  • Removed lines — present in the old version, gone in the new — are marked in red, often with a leading -.
  • Added lines — new in the second version — are marked in green, often with a leading +.
  • A changed line is really a removal plus an addition: the old line in red, the new line in green, right next to each other.

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.

Line diff vs. word diff

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.

Try it: Compare two texts free → Paste both versions and see every change highlighted.

Everyday uses beyond code

  • Contracts and documents. Confirm exactly which clauses a counterparty edited before you sign.
  • Configuration files. See what changed between a working setup and a broken one — the cause is often a single altered line.
  • Writing and editing. Compare a draft against an editor's revision to review every change.
  • Logs and data. Diff two output files to find the one record or value that differs.
  • Spotting accidental changes. Before saving over a file, diff it against the original to make sure you only changed what you meant to.

Things that trip people up

A few non-obvious factors change what a diff reports:

  • Whitespace. Trailing spaces and tab-vs-space differences are invisible to the eye but show up as changes. Many tools offer an “ignore whitespace” option for exactly this.
  • Line endings. A file edited on Windows (CRLF) versus Unix (LF) can appear to differ on every single line. Normalise line endings first if you see that.
  • Reordering. Moving a block of lines usually shows as a deletion in one place and an addition in another, not as a “move” — the two halves are the same content.

How to use a diff effectively

  1. Put the original on the left and the new version on the right, consistently, so red always means “was” and green always means “now”.
  2. If comparing prose, switch on word-level highlighting so you are not rereading whole paragraphs.
  3. If everything lights up as changed, suspect whitespace or line-ending differences and turn on the option to ignore them.
  4. Scan the green and red blocks; the unchanged context between them is just there to orient you.

The takeaway

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.

Try these free tools

No signup, no watermark — works in your browser.

  • 🔀Text Diff
    Open tool →
  • 🔍Text Similarity
    Open tool →
  • 📝Online Notepad
    Open tool →
  • 🔍Regex Tester
    Open tool →

← Blog index  |  Quick guides  |  All tools

We use cookies for analytics and to show ads. Learn more