DevKitHub

Programming

Text Diff Checker

Paste two versions of a file or snippet to see a line-by-line comparison. Whitespace and case can optionally be ignored.

0 lines
0 lines

This tool runs entirely in your browser. Your input is never uploaded, stored or logged.

How it works

The comparison finds the longest common subsequence of lines — the largest set of lines appearing in the same order in both inputs. Everything in that set is unchanged; everything else is an addition or a removal. This is the same general approach the diff command uses.

Working line by line has a consequence worth knowing: a block of text that moved is reported as a removal in one place and an addition in another, because its lines are no longer in a common order. The content is identical, but its position is the thing that changed.

Ignoring whitespace or case changes only the comparison, never the output. Lines are normalised to decide whether they match, and then the original text is displayed — so a line that differs only in indentation is reported as unchanged while still showing you its real indentation.

Common problems

Every example below is run against this tool in our test suite, so what it says here is what the tool actually does.

Everything shows as changed

Why:
Usually mismatched line endings. A file saved with Windows CRLF compared against one with Unix LF differs on every single line.
Fix:
Normalise line endings first, or enable "Ignore whitespace".

A block of code that only moved is reported as deleted and added again.

Why:
The comparison matches lines in order, so a block that appears in a different position is no longer part of the common subsequence even though its text is unchanged.
Fix:
Nothing is wrong with the diff. Read the pair together, or compare the moved block against its old position on its own.

Two lines that look identical are reported as different.

Why:
Invisible characters: a trailing space, a tab where the other side has spaces, a non-breaking space pasted from a document, or a zero-width character from a web page.
Fix:
Turn on "Ignore whitespace" to confirm, then strip the character at the source — a diff that depends on invisible bytes will keep resurfacing.

Frequently asked questions

How is the comparison calculated?
It uses a longest-common-subsequence algorithm over lines, which is the same general approach used by standard diff tools. Lines are matched in order, so moved blocks appear as a removal plus an addition.
Is my text uploaded anywhere?
No. The comparison runs entirely in your browser. Neither side of the diff is transmitted or stored.

Last updated