Text Diff Checker

Compare two pieces of text or code and see exactly what changed — line, word or character granularity, with the specific changed span highlighted inside each changed line, not just a wall of red and green.

{{ (left.match(/\n/g) || []).length + (left ? 1 : 0) }} lines

{{ (right.match(/\n/g) || []).length + (right ? 1 : 0) }} lines

Granularity

Paste or drop Text A and Text B above to compare them.

Both documents are diffed entirely in your browser. Neither one is ever uploaded to a server.

Why this isn't just "highlight the lines that differ"

Comparing line by line in sequence would report that inserting one line at the top of a file changes every single line after it — technically true character-for-character, useless in practice. This tool instead finds the shortest edit script: the minimum number of line insertions and deletions that turns Text A into Text B, using the Myers diff algorithm — the same category of algorithm behind git diff and the Unix diff command. A line that was moved rather than genuinely rewritten is recognised as unchanged wherever it still matches exactly.

Within a line marked "changed," a second diff pass at the word level finds exactly which part of the line changed, rather than coloring the whole line as one big edit — a one-word fix in a long sentence shows as a one-word highlight, not a wall of red and green.

What kind of diff is this — and what it isn't

This is a line-oriented text diff, the same kind git diff produces without a language-specific driver — not a language-aware structural diff. Moving a function from the top of a file to the bottom will show as a full delete-and-reinsert of that function, because the tool compares text by line position, not by parsing your code's actual structure. For structural comparison of two JSON documents specifically, use JSON Diff instead.

How is this different from the JSON Diff tool?

JSON Diff parses both documents and compares the resulting structure, so re-indenting or reordering keys never shows up as a difference. This tool compares plain text or code line by line instead, the same way git diff does — the right tool when your input isn't JSON, or when line-level changes are exactly what you want to see.

Why doesn't inserting one line at the top mark the whole file as changed?

Because this uses the Myers diff algorithm to find the shortest edit script — the minimum number of line insertions and deletions that turn Text A into Text B — rather than comparing line 1 to line 1, line 2 to line 2, and so on in fixed lock-step, which is what would make one inserted line cascade into every line after it looking different.

What does the highlighted span inside a changed line mean?

A second, finer diff runs specifically between the two versions of a line marked "changed," so only the actual changed word or phrase is highlighted — a one-word fix in a long line shows as a one-word highlight, not the entire line colored as an edit.

What is a unified diff / .patch file?

The standard --- / +++ / @@ format that git diff and the Unix patch command both produce and understand. Copying the output in this format means it's immediately usable with real diff/patch tooling, not a format only this page understands.

Can this diff two source code files in different languages meaningfully?

It compares them as plain text, line by line — it doesn't parse either language's syntax. A function that moved from the top of a file to the bottom will show as a full delete-and-reinsert, the same limitation git diff has without a language-specific driver.

Is my text uploaded anywhere?

No. Both documents are diffed entirely in your browser using JavaScript. Nothing is transmitted to a server.