Diff Checker — Compare Text

Compare two blocks of text and see exactly which lines were added, removed or left alone. Runs in your browser; nothing is uploaded.

All processing happens in your browser. Nothing is uploaded.

How to use

  1. Paste the original text on the left and the changed text on the right.
  2. Differences appear immediately; added lines are green, removed lines are red.
  3. Turn on Ignore leading/trailing whitespace when indentation changed but content did not.
  4. Collapse unchanged lines hides long stretches of identical content, keeping three lines of context around each change.

About comparing text

The obvious way to compare two texts — line 1 against line 1, line 2 against line 2 — falls apart the moment a line is inserted. Everything after the insertion shifts by one, and every line gets reported as modified. The output is technically correct and practically worthless.

What produces a readable diff is finding the longest common subsequence: the longest set of lines appearing in both texts in the same order, though not necessarily adjacently. Those lines are the unchanged ones; everything else is an insertion or a deletion. This is how git diff and every other serious comparison tool works.

The cost is that the classic algorithm builds a table of every line on one side against every line on the other. Two five-thousand-line files mean twenty-five million cells — enough to make a browser tab unresponsive. The fix that makes it practical is to strip the identical leading and trailing lines first, because in real comparisons most of the file has not changed. Two twenty-thousand-line files differing in one line reduce to a comparison of roughly one line against one line.

One thing worth knowing when a diff looks unexpectedly large: line endings. A file saved on Windows ends its lines with a carriage return plus a line feed; on Unix, just a line feed. Those are genuinely different bytes, and a comparison that does not normalise them reports every single line as changed. This tool normalises them, which is almost always what you want — but if you are specifically hunting a line-ending problem, that is exactly the difference it will hide.

Frequently asked questions

Why does inserting one line at the top not mark everything as changed?

Because the comparison finds the longest common subsequence rather than comparing line 1 to line 1, line 2 to line 2 and so on. A naive line-by-line comparison reports every line after an insertion as modified, which is technically true and completely useless. Finding the longest run of shared lines is what makes the result readable.

Are Windows and Unix line endings treated as differences?

No. Line endings are normalised before comparison, so the same file saved on Windows (CRLF) and on Linux (LF) shows as identical. This is deliberate — that difference is real at the byte level but almost never what you are looking for.

Is my text uploaded?

No. The comparison runs in your browser. This matters more here than for most tools, since diffing usually involves two versions of something you have not published — a contract draft, an unreleased config, a patch.

What does 'too different to compare' mean?

The algorithm builds a table sized by the number of lines on each side multiplied together. Two files with no lines in common and a few thousand lines each would need millions of cells, enough to freeze the tab. Identical leading and trailing lines are stripped first, which handles most real comparisons; when that is not enough the tool declines rather than hanging.

Can it show changes within a line?

Not currently — a modified line is shown as one removal plus one addition. Line-level comparison is what makes the result stable and predictable; character-level highlighting inside a line is a possible future addition.

Should I use this instead of git diff?

They answer different questions. git diff compares tracked versions of files in a repository. This is for the case where two pieces of text are simply in front of you — pasted from an email, a chat message, two API responses — with no repository involved.