Text Diff & Compare

Paste two versions of anything and see precisely what changed, at line level and word level, with a unified diff you can copy.

Original
Changed
Line differences
Unified diff

Line diff versus word diff

A line-level diff answers which lines moved. That is what a patch file needs, and it is fast. But when you edit a single word in a 200-character line, a line diff reports the whole line as removed and re-added — technically true, and almost useless for reading.

A word-level diff runs a second comparison inside each changed line pair, so you see the actual words that changed. This tool does both: the coloured view is word-level where it can be, and the unified diff below it is line-level and patch-compatible.

How the comparison works

Both sides are treated as sequences of lines, and the tool computes a longest common subsequence — the longest set of lines that appears in both files in the same order. Everything not in that subsequence is an insertion or a deletion.

It is the same algorithm family that powers git diff and diff, and it has one property worth knowing: it minimises the number of changed lines, but it has no concept of a move. Relocate a function from the top of a file to the bottom and the diff reports a deletion at the top and an insertion at the bottom, even though nothing was really rewritten.

Diffs compare text, not meaning. Reformatting a file with a different formatter produces a large diff that changes no behaviour. This is why teams commit formatting changes separately from logic changes, and why "ignore whitespace" exists as an option above.

Reading a unified diff

Each changed region is a hunk introduced by a line like @@ -12,7 +12,8 @@, which reads as "starting at line 12 of the original, 7 lines; starting at line 12 of the result, 8 lines". Within the hunk, a leading space is context, - is a deletion and + is an insertion. The context lines are what let patch and git apply locate the change even when line numbers have shifted.

Frequently asked questions

Why is my diff bigger than expected?

Usually line endings. A file converted between CRLF and LF differs on every single line. Turn on Ignore whitespace, which collapses line-ending differences.

Can I diff large files?

Yes, within your browser's memory. The comparison is quadratic in the worst case, so the tool trims the identical prefix and suffix first — which makes typical edits fast even on long files.

Is this the same as git diff?

The output format is compatible. Git additionally tracks renames and binary files, and uses a slightly different hunk-splitting heuristic, so a very large diff may group hunks differently.

Does it show moved blocks?

No. Detecting a move requires a different algorithm plus a similarity threshold. A move is reported as a delete plus an insert.

Privacy. Both sides stay in your browser. Nothing is uploaded, so you can diff configuration files, contracts and unreleased code without sending them anywhere.