Word-level highlightingWhitespace controlsUnified patch output

Text & Code Diff Viewer

Compare two blocks of text with numbered line diffs, word-level highlighting inside changed lines, and whitespace handling you control. All processing happens locally in your browser.

Line and word comparison

Compare two blocks of text side by side

Lines are aligned with the Myers algorithm, then changed line pairs are compared again word by word so you can see what moved inside a line rather than just that it changed.

Lines added
Lines removed
Lines unchanged
Lines in common
Side AOriginal
Side BModified
What counts as a difference

Paste text into both panels to see the differences.

Load sampleLoad a comparison

What is a diff, and how are lines matched up?

A diff answers one question: what is the smallest set of edits that turns text A into text B?

The answer comes from finding the longest common subsequence — the longest sequence of lines that appears in both versions, in order, though not necessarily adjacent. Everything in that sequence is unchanged. Everything else is an insertion or a deletion. The Myers algorithm, which this page uses through the diff library, is the standard way to compute it and is what git diff uses too.

One consequence is worth knowing: a diff has no concept of "modified". A changed line is a deletion followed by an insertion. That is why a one-character typo fix shows as - and + rather than a single "edited" row.

This page reunites those pairs for display and then compares them again at word level, so you can see that only one word changed rather than being told the whole line is different.

Line, word and character granularity

The three modes answer the same question at different resolutions. The line alignment is identical in all three; only what happens inside a changed pair differs.

Take timeout = 30 becoming timeout = 300:

Mode What you see Best for
Line The whole line marked removed, the whole line marked added Structural changes, reviewing whole blocks, matching what git shows
Word Only 30300 highlighted Prose, config values, most day-to-day review
Character Only the added 0 highlighted Minified code, hashes, single-character typos, invisible characters

Word mode is the sensible default for most text. Character mode becomes noisy on prose — reordering a sentence produces a shredded highlight — but it is exactly right when you are hunting a single wrong digit in a long token.

How to compare two versions

  1. Paste the original on the left, the changed version on the right Side labelling matters: - rows come from the left and + rows from the right. Swap the sides if you pasted them the wrong way round.
  2. Choose the granularity Word is a good starting point. Switch to character when a change is smaller than a word, or to line when word highlighting is too busy.
  3. Adjust what counts as a difference Line-ending normalisation is on by default because a CRLF versus LF mismatch otherwise reports every single line as changed. The other options are off so nothing is hidden without you asking.
  4. Read the aligned result Both original and new line numbers are shown, so a row tells you where the text is in each version rather than just that it changed.
  5. Export a unified patch if you need one The unified diff is the format git apply and patch accept, with three lines of context.

False differences: when text looks identical but is not

This is the single most common reason a diff is confusing. Several characters are invisible in an editor but count as changes, and this page names them explicitly rather than leaving you to guess.

Cause Why it happens What you see
CRLF vs LF line endings One file was saved on Windows, the other on macOS or Linux Every line reported as changed
Trailing whitespace An editor without trim-on-save Lines differ with no visible cause
Tabs vs spaces Different editor settings Indentation reported as changed
Missing final newline One version lacks the trailing newline Only the last line differs
Byte-order mark (U+FEFF) Saved as UTF-8 with BOM Only the first line differs
Non-breaking space (U+00A0) Text pasted from a web page or Word A word differs with no visible change

The last two are the ones that waste real time, because nothing in the rendered text hints at them. When the diff says two apparently identical lines differ, a BOM or a non-breaking space is the usual explanation, and switching to character mode makes the position obvious.

Note on the ignore options: they change what is compared, not what is displayed. With "ignore all whitespace" on, lines differing only in spacing are treated as equal, but the original text is still shown so you can see what is actually there.

Examples of what the output looks like

A configuration change, in word mode:

 1  1   host = localhost      →  host = api.internal
 2  2   port = 8080           →  port = 8443
 3  3   timeout = 30              (unchanged)
 4  4   retries = 3           →  retries = 5
    5  + tls = true

Line 5 exists only on the right, so it has no left-hand number. That asymmetry is what makes numbered diffs useful for review: you can reference "line 4 in the old version" and "line 4 in the new version" without ambiguity.

The same change as a unified patch:

@@ -1,4 +1,5 @@
-host = localhost
-port = 8080
+host = api.internal
+port = 8443
 timeout = 30
-retries = 3
+retries = 5
+tls = true

The @@ -1,4 +1,5 @@ header means "4 lines starting at line 1 in the original become 5 lines starting at line 1 in the new version".

What this tool does not do

  • No merging. This is a comparison view, not a three-way merge. There is no common ancestor, no conflict resolution and no way to apply changes from one side to the other. Git, or your editor's merge tool, is the right place for that.
  • No move detection. A block moved from the top of a file to the bottom is reported as a deletion plus an addition, not as a move. That is standard diff behaviour, and it is why reordered lists look like large changes.
  • No syntax awareness. Comparison is on text, not on parsed structure. Reformatting JSON without changing any value still produces a large diff. For that specific case, comparing parsed structures with the JSON Diff tool gives a much smaller and more meaningful result.
  • No files. Text is pasted rather than uploaded. Open the files and copy the contents across.
  • No binary comparison. Line-based diffing is meaningless for images or compiled output.

Practical limits: the aligned view renders the first 2,000 rows. The unified patch always covers the full comparison, so nothing is lost from the exportable output.

Use cases

  • Reviewing a config change before deploying. Comparing the current and proposed versions of a config file catches an unintended edit that a code review might skim past.
  • Checking what an AI or a formatter changed. Paste before and after to see the actual edits rather than trusting a summary.
  • Comparing API responses across environments. Staging and production payloads side by side reveal which fields differ.
  • Proofreading two drafts. Word mode reads naturally on prose and shows exactly which phrases were rewritten.
  • Diagnosing "it works on my machine". Compare two dependency lock files, two environment variable dumps, or two versions of the same script.
  • Verifying a manual data migration. Compare the exported source and the transformed output row by row.
  • Finding an invisible character. When a string comparison fails in code but the values look the same, character mode plus the invisible-difference notes usually pinpoint it in seconds.

Privacy

Both texts stay in the page. Comparison runs in your browser and nothing is uploaded or written to storage, which matters when you are diffing production configuration or unpublished content.

Frequently Asked Questions

Why is every single line marked as changed?

Nearly always a line-ending mismatch: one side uses CRLF and the other LF, so no line matches byte for byte. Line-ending normalisation is on by default to prevent this, and the tool reports the mismatch explicitly when it sees one.

Two lines look identical but the diff says they differ. What is going on?

Something invisible. The usual suspects are trailing whitespace, a tab where the other side has spaces, a non-breaking space (U+00A0) pasted from a web page, or a byte-order mark on the first line. Switch to character mode and the highlight will land on the exact position.

Why does a moved block show as a deletion and an addition?

Because the algorithm finds the longest common subsequence, which is order-sensitive. Moved text is not in the same relative position in both versions, so it cannot be part of that sequence. Every standard diff tool behaves this way, which is why reordering a list produces a bigger diff than it feels like it should.

Can I compare files rather than pasted text?

No, this page works on pasted text. That keeps everything in the browser with no upload path at all. Open both files, copy the contents into the two panels, and the comparison is the same.

Does the ignore-whitespace option change my text?

No. It changes what is compared, not what is shown. Lines that differ only in whitespace are treated as equal, but the panels and the diff still display your original text exactly as pasted.

What is a unified diff and when would I use one?

It is the patch format git and the patch command use, showing changed lines with three lines of surrounding context and @@ headers giving line positions. Use it when you want to attach a change to a ticket, paste it into a review, or apply it with git apply.

Why is my JSON diff enormous after reformatting?

Because text comparison sees changed indentation and reordered keys as real changes even though the data is equivalent. Format both sides identically first, or use the JSON Diff tool, which compares the parsed structure and ignores formatting entirely.