PlayTools

Diff Checker

Compare two blocks of text and see a line-by-line diff with added and removed lines highlighted, plus options to ignore whitespace and case.

Runs in your browser — nothing you enter is uploaded

Added

+0

Removed

−0

Unchanged

1

Paste text into both boxes to compare.

This is a line-level diff computed with a longest-common-subsequence algorithm: lines present in both texts are the anchor, and everything else is marked added (in the changed text) or removed (from the original). It does not highlight within-line character changes. The comparison runs entirely in your browser — paste code, config or prose freely.

How a text diff is computed

A diff answers a precise question: what is the smallest set of line additions and deletions that turns the first text into the second? This tool answers it with the classic approach — split both texts into lines, find their longest common subsequence (the longest run of lines that appears in both, in the same order), and treat every line not on that path as added or removed.

The longest-common-subsequence choice matters. It means moved blocks, inserted paragraphs and deleted sections are all reported as local changes rather than making everything after them look different. Lines that appear in both texts act as anchors that keep the two sides aligned. Each row shows the line number in the original text, the line number in the changed text, a +/− marker, and the line itself.

This is a line-level diff, not a character-level one. If a single word in a line changes, the whole old line is marked removed and the whole new line added — there is no inline word highlighting. That keeps the output simple and predictable, and it is what most code review and "what changed" tasks actually need.

The two options change how lines are matched, not how they are shown. "Ignore whitespace" trims each line and collapses internal runs of spaces before comparing, so reindented code or reflowed prose still lines up. "Ignore case" makes lines that differ only in capitalisation count as unchanged. For diffing JSON or code, formatting both sides with consistent indentation first gives the cleanest result.

The comparison runs entirely in your browser, so you can paste private code or documents. Unchanged lines at the start and end are matched before the table is built, so long files with a localised edit compare quickly; only very large rewrites — thousands of changed lines on both sides — are too big to compare here.

Key formulas (reference)

lines A, lines B → LCS table  dp[i][j] = length of longest common subsequence of A[i:], B[j:]
walk from (0,0): equal line → keep (unchanged)
  else step toward the larger of dp[i+1][j] (delete A[i]) / dp[i][j+1] (add B[j])

Worked example

Original:    Changed:
a            a
b            c
c            d
d            e

Result:
  1 1  a
− 2    b
  3 2  c
  4 3  d
+   4  e

Line b was removed and line e added; a, c and d are unchanged and keep both line numbers. A line that was edited — even by one character — appears as a removal plus an addition.

Getting a readable diff

  • Format both sides the same way first. For JSON, run both through the JSON formatter with the same indentation; for code, use the same formatter settings — otherwise every line looks changed.
  • Turn on “ignore whitespace” for re-indented code, and “ignore case” for SQL keywords or headings whose capitalisation changed.
  • Long files with a few edits compare instantly, because identical lines at the start and end are matched before the comparison table is built.
  • For whole documents that were heavily rewritten, compare section by section; very large rewrites are better handled by git diff or a desktop diff tool.

These free tools pair well with this page — open them in a new tab to finish your workflow.

Frequently Asked Questions

What kind of diff is this?

A line-level diff. The two texts are split into lines and compared with a longest-common-subsequence algorithm: lines that appear in both, in order, are the unchanged anchor, and everything else is shown as added (present in the changed text) or removed (present only in the original).

Does it highlight changes within a line?

No. If a single word changes, the whole old line shows as removed and the whole new line as added. Character-level highlighting is a separate feature this tool does not do.

What do "ignore whitespace" and "ignore case" do?

They affect only how lines are matched, not how they are displayed. "Ignore whitespace" collapses runs of spaces and trims each line before comparing, so re-indented code lines up. "Ignore case" makes "Hello" and "hello" count as the same line.

What do the two number columns mean?

The first is the line number in the original text, the second is the line number in the changed text. Unchanged rows have both; a removed row has only the original number; an added row has only the changed number.

Can I diff code or JSON?

Yes — paste anything. For JSON specifically, formatting both sides with the JSON Formatter first (same indentation) makes the diff far more readable, since the algorithm compares lines as text.

Is there a size limit?

Identical lines at the start and end are matched first, so even long files compare quickly when only part of them changed. The rest uses a table proportional to (changed lines in A) × (changed lines in B); if that would exceed about 25 million cells — roughly 5,000 changed lines on each side — the tool says so instead of freezing the tab. For larger rewrites, use git diff or a desktop diff tool.

Is my text uploaded?

No. The comparison runs entirely in your browser. You can paste private code or documents; nothing is sent anywhere.