Text Diff Checker — compare two pieces of text
Paste two versions of any text and see line-by-line and word-by-word differences highlighted side by side. Uses the same minimal-edit LCS algorithm as GNU diff and git diff. Free, no signup, runs entirely in your browser.
How it works
The tool finds the smallest set of inserts and deletes that turn the original text into the modified text. It does this by computing the Longest Common Subsequence (LCS) of the two line arrays — the longest sequence of lines that appears in both texts in the same relative order. Every line that is part of the LCS is shown as unchanged; lines outside it are either removed or added.
The classical formulation, attributed to Wagner and Fischer (1974) and to Aho, Hopcroft & Ullman's textbook treatment, fills a (m + 1) × (n + 1) dynamic-programming table where the cell at (i, j) stores the LCS length of the first i lines of the original and the first j lines of the modified. The recurrence is:
if a[i] == b[j]: dp[i][j] = dp[i-1][j-1] + 1 else: dp[i][j] = max(dp[i-1][j], dp[i][j-1])
After the table is filled, a single backtrack from (m, n) to (0, 0) reconstructs the actual edit script — equal, insert, or delete at each step. Eugene Myers (1986) later published an O(N · D) variant that is faster when the edit distance D is small; GNU diff and git diff both implement Myers. For browser-side use up to 2,000 lines per side, the classical O(m · n)DP is fast enough — well under 100 ms in V8 — and produces an identical edit script.
When a deleted line is followed immediately by an inserted line, the tool runs a second LCS pass at the wordlevel (treating each run of whitespace and each run of non-whitespace as one token) and paints the changed words on top of the line. That is what makes the side-by-side view show in-place edits as a single "modified" row instead of two unrelated "delete" and "insert" rows.
For confidence, the diff result is cross-checked. The page computes the LCS length once via the full DP backtrack and once via a space-efficient two-row DP. The number of unchanged lines must match across both methods; if it does not, the "Verified" badge flips to a warning so you know to report it. Comparison is byte-faithful — the tool does not normalise Unicode unless you ask it to ignore case or whitespace.
Worked examples
Frequently asked questions
Sources & references
- Eugene W. Myers (1986) — An O(ND) Difference Algorithm and Its Variations (PDF)
- Longest Common Subsequence problem — formulation and DP recurrence
- GNU diffutils manual — Detailed description of the unified diff format
- git-diff(1) reference — algorithm choices (myers, minimal, patience, histogram)
- ECMA-262 §22.1.3.21 — String.prototype.split semantics
Implementation last cross-checked against the references on 2026-05-11. Every diff produced by this page is also verified at runtime by a second, independent LCS pass.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.