Text Diffing, Quick Facts
- •A diff finds the longest common subsequence between two texts, everything else is marked as added or removed.
- •Line-level diffing (comparing whole lines) is the standard for code and config files; it's what
git diffand most code review tools show by default. - •A single character change on a line still marks the whole line as changed (shown as one removed line plus one added line) in a line-level diff.
- •"Ignore whitespace" is useful for comparing files reformatted by different editors, where the content is identical but indentation or line endings differ.
The Real Problem This Solves
Two versions of a config file, two drafts of a document, two API responses that should be identical but aren't, eyeballing them side by side to spot what changed is slow and error-prone, especially past a few dozen lines.
This tool computes the actual minimal difference and highlights only what changed, so you're not scanning irrelevant unchanged lines.
How the Diff Is Computed
The tool splits both texts into lines and finds the longest common subsequence (LCS): the longest run of lines that appears, in order, in both versions. Any line in the original that isn't part of that shared sequence is marked removed; any line in the modified version that isn't part of it is marked added. This guarantees the smallest possible set of changes that explains the difference, not just any set that happens to work.
Example: changing "jumps over the lazy dog" to "jumps over the sleepy dog" shows as one line removed and one line added, even though only one word changed, because this is a line-level diff. The surrounding unchanged lines stay untouched in the output.
Frequently Asked Questions
Why does changing one word mark the whole line as different?
This is a line-level diff, the standard approach for comparing code and config files, since it treats each line as the smallest unit of comparison. A word-level diff would highlight just the changed word, but is noisier for most practical uses like comparing files or code.
What does "ignore whitespace" actually ignore?
It trims leading and trailing spaces and collapses repeated internal spaces on each line before comparing, so a file re-indented with tabs vs spaces, or with trailing whitespace stripped, won't show as changed when the actual content is identical.
Is this the same algorithm git diff uses?
It's the same core idea, the longest common subsequence, which is the foundation of the Myers diff algorithm that git and most diff tools use. Production tools add further optimisations for speed on huge files, but the result on typical inputs is the same minimal diff.
Why does it say my input is too large?
The diff runs entirely in your browser, and the comparison algorithm's memory use grows with the product of both texts' line counts. Very large files (several thousand lines) are capped to keep the page responsive; try comparing smaller sections instead.
Is my text uploaded anywhere?
No. Both texts are compared entirely in your browser; nothing is sent to a server.
Diffing raw HTML or XML source?
Special characters like < and & can make a diff harder to read at a glance. Escape or decode them first with our HTML Entity Encoder/Decoder.
Open HTML Entity Encoder/Decoder →