Comparing “before” and “after” to surface only what changed—that is a diff. You use it in Git code review, comparing config-file backups, reconciling API responses, and more.

How to Read Text Diffs: Understanding Line-Level and Word-Level Comparison

This article explains the basics of reading diffs, the difference between line-level and word-level comparison, and practical usage, with concrete examples.

The Basics: What + and - Mean

The most common unified diff format uses a leading symbol on each line. For the @@ hunk headers, combined @@@ diffs on merges, and rename detection, see the unified diff format reference.

 function greet(name) {
-  return "Hello " + name;
+  return `Hello ${name}`;
 }
  • Lines starting with - (red) are removed lines
  • Lines starting with + (green) are added lines
  • Unmarked lines are unchanged (shown for context)

So when you “modify” a line, a diff represents it as deleting the old line and adding the new one.

Line-Level vs. Word-Level

Diffs come in two main granularities.

Line-level (line diff)

Judges each line as “same or different.” Good for code and config files. The downside: even a one-character change shows the whole line as changed, so you can’t see which word changed.

Word/character-level

Highlights which part within a line changed. It shines for proofreading text and comparing long single lines (such as minified JSON).

Consider this change:

Before: The price is 1000 yen excluding tax
After:  The price is 1100 yen including tax

A line diff only tells you “this line changed,” but a word diff highlights just “excluding→including” and “1000→1100,” making the change obvious at a glance. The site’s Diff tool also highlights the words that changed inside a changed line; on the command line, git diff --word-diff gives a similar view.

The Whitespace and Line-Ending Trap

Sometimes a diff shows “every line changed,” which is surprising. The cause is usually an invisible difference.

  • Line endings: mixing Windows CRLF and Unix LF flags every line as different.
  • Indentation: tabs vs. spaces, or trailing spaces.
  • Full-width vs. half-width spaces: they look almost identical but are different characters.

To see only meaningful changes, normalize line endings, indentation and trailing whitespace before comparing. The site’s Text Diff tool lets you ignore whitespace and letter case (with git, git diff -w ignores whitespace). Without the option, differences such as trailing spaces show up as-is. Line endings (CRLF / LF) and a missing newline at the end of the text are never reported, whatever the settings. Conversely, when whitespace itself matters (as in some config files), compare as-is.

Actual comparison results

The Text Diff tool compares line by line. Here are real inputs and results.

Before → After Result
a b c → a B c b removed, B added. a and c unchanged
Last line without a newline …c → with one …c⏎ No difference (a missing final newline is ignored)
Line endings CRLF → LF (same two lines of content) No difference (line-ending differences are ignored)
b → b␣ (one space added at the end of the line) That line shows as removed and added (no difference with “Ignore whitespace” on)
x y z → z x y (z moved to the top) z added at the top and the final z removed (not shown as a “move”)
a b → a blank line b One blank line is added
Identical content No difference

Points to watch.

  • A newline at the end of the file, or the lack of one, makes the last line look changed. Check whether your editor adds a trailing newline automatically.
  • Mixed line endings make every line a difference even though they look identical. Normalize to either CRLF or LF before comparing.
  • A moved line shows up as “added + removed”. If you only swapped blocks, you can tell by checking whether the same content appears on both sides.

Practical Uses

  • Self-review before code review: review your changes before committing to catch leftover debug code or unintended edits.
  • Comparing config files: line up the .env or config of a working vs. broken environment and isolate the cause from the diff.
  • Reconciling API responses: compare the expected JSON with the actual response to find missing fields (format single-line JSON first for readability).
  • Proofreading text: compare a draft before and after edits at the word level to confirm what changed.

Compare Sensitive Data Locally

Config files and logs may contain API keys or personal data. Pasting such data into an external online service is best avoided. The text diff tool processes everything inside your browser and never sends your input to a server. With the Network tab open, you can confirm no requests fire when you compare.

New in November 2026

  • Compare inside the input boxes: while you type, removed lines are shaded red on the left and added lines green on the right, with line numbers.
  • Merge: for each change you can pick left, right or both. A 3-way merge takes a common base and two versions, detects conflicts and lets you resolve them one by one.
  • Also new: ignore blank lines, sort lines before comparing, word or character highlighting inside a line, applying a patch from git diff / diff -u, and much faster handling of large, fully different inputs.

Try it in the tool

Frequently Asked Questions

Why does changing one line produce a two-line diff?

Because a diff expresses a “change” as a “delete plus add.” The original line appears as - and the new one as +, so a one-line edit looks like two lines. A tool that compares by word (with git, git diff --word-diff) highlights only the part that actually changed.

The diff shows every line as changed.

This is often caused by differing line endings (CRLF vs. LF), trailing whitespace, or mixed tabs/spaces in indentation. Normalize line endings, trailing whitespace and indentation before comparing; with git, git diff -w ignores whitespace differences. In the site’s Diff tool, turn on “Ignore whitespace” to drop differences in the amount of whitespace and trailing spaces (line-ending differences are never reported).

Can it handle large files?

Browser-based tools can get sluggish with extremely large files. In that case, extract just the range you need to compare, or use command-line diff or git diff alongside. For everyday code and config comparisons, a browser-based tool is plenty practical.