induwara.lk
induwara.lkText · Compare

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.

By Induwara AshinsanaUpdated May 11, 2026
Compare two pieces of text
Files never leave your device.0 lines · 0 chars
Files never leave your device.0 lines · 0 chars
Options
Added
Removed
Unchanged
Similarity
Paste text into both boxes above to see a line-by-line and word-by-word diff. Click Sample to load an example.

Runs entirely in your browser. Nothing is uploaded, logged, or stored. Diff method: Longest Common Subsequence (LCS) DP, the same minimal-edit basis as GNU diff and git diff. Maximum 2,000 lines and 200,000 characters per side.

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

Word edited mid-sentence

Original

The quick brown fox jumps over the lazy dog.

Modified

The quick brown fox jumps over a lazy cat.
  1. Both sides are one line, so the line-level LCS pairs the line as a modification.
  2. Word LCS: the sequence "The quick brown fox jumps over" is common.
  3. Inline diff shows: "the" → "a" and "dog." → "cat."
  4. Stats: 1 added, 1 removed, 0 unchanged, 1 modified, similarity 0%.

One inserted line in the middle

Original

alpha
beta
gamma

Modified

alpha
beta
DELTA
gamma
  1. Line LCS: [alpha, beta, gamma], length 3.
  2. Backtrack: equal alpha, equal beta, insert DELTA, equal gamma.
  3. Stats: 1 added, 0 removed, 3 unchanged, 0 modified.
  4. Similarity = 3 / max(3, 4) = 75%.

Whitespace-only difference (with Ignore whitespace on)

Original

  hello   world  
foo

Modified

hello world
foo
  1. Without options: the first lines have different keys, line LCS finds [foo] only.
  2. Enable Ignore whitespace: each line's whitespace is stripped before comparison.
  3. Canonical keys become ["helloworld", "foo"] on both sides.
  4. Stats: 0 added, 0 removed, 2 unchanged, similarity 100%.

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

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.