Text Diff Checker
Paste text, or load a file.
Paste text, or load a file.
- 2
- Added
- 1
- Removed
- 2
- Unchanged
The diff compares two pieces of text and shows which lines were added, removed or left alone, with line numbers from both sides. Either side accepts pasted text or a loaded file, so you can compare two files, two snippets, or a snippet against a file. Nothing is uploaded.
How it works
The comparison finds the longest common subsequence of lines, the longest ordering of lines that appears in both, in the same order. Everything outside it is an addition or a removal. That is why moving a block produces a removal and an addition rather than a "moved" marker: a line diff has no concept of a move.
- Ignore case compares lines without regard to capitalisation, which is useful for prose and wrong for code.
- Ignore whitespace collapses runs of spaces and trims each line, so a reindentation stops swamping the real changes.
- Ignore blank lines removes them before comparing, which helps when one file uses blank lines more liberally.
- The three ignore options change the comparison, not the output. The lines shown are still exactly as they appear in your text.
The algorithm builds a table with one cell for every pair of lines, so memory grows with the product of the two lengths. Input is capped at 2,000 lines per side; beyond that, a desktop diff or git is the right tool.
Examples
One word changed
Line
"jumps over" becomes "leaps over"
Result
1 removed, 1 added
A line diff has no sub-line resolution, so a one-word change is a whole line replaced. That is how git reports it too.
A line appended
Change
A fourth line added at the end
Result
1 added, 3 unchanged
The three original lines stay in the common subsequence and are marked unchanged, with only the new line flagged.
Reindented code
Options
Ignore whitespace, on
Result
Identical, where only the indentation changed
Without the option every line reads as changed. With it, a whitespace-only reformat correctly shows no differences.
Frequently asked questions
Why is a one-word change shown as a whole line replaced?
Because the comparison works on lines, which is the standard granularity for a diff and the same thing git does by default. A word-level diff inside changed lines is a different algorithm; for prose where that matters, shorter lines give a more useful result.
Do the files I compare leave my machine?
No. Files are read with the browser file API and compared in the page. That matters for the usual reason people diff files. Configuration, exports and contracts are rarely things you want to hand to an unknown web service.
Why does moving a block show as both a removal and an addition?
Because a longest-common-subsequence diff preserves order, so a block appearing in a different position cannot be part of the common subsequence. Detecting moves needs a separate pass that matches removed blocks against added ones, which this does not do.
What does ignoring whitespace actually compare?
Each line is trimmed and internal runs of whitespace collapse to a single space before comparison. The lines displayed are unchanged. Only the matching is affected. Use it after a reformat, and turn it off for anything where indentation is significant, such as Python or YAML.
Why is there a 2,000-line limit?
The algorithm allocates a table with one cell per pair of lines, so two 2,000-line files already means four million cells. Ten thousand lines each would be a hundred million, which a browser tab will not survive. Above that limit, use git diff or a desktop tool.