Text Diff

Compare two texts and see exactly what changed, in a side-by-side or inline view, at line or word level.

All calculations happen locally in your browser. Nothing leaves your device.

How the Diff Works

Comparing two texts is a classic computer science problem: find the smallest set of edits that turns one into the other. This tool solves it with the longest common subsequence (LCS) algorithm — it finds the longest sequence of lines (or words) shared by both texts in the same order, and everything else is reported as an addition or a removal. No server, no network, just your two texts and a bit of dynamic programming in your browser.

LCS algorithm
Given two sequences, LCS asks: what is the longest subsequence of elements present in both, in the same order? It is solved with dynamic programming in O(n·m): a table where each cell stores the best answer for the prefixes up to that point. Walking the table backwards yields the alignment — matching lines are equal, the rest are additions and removals. The famous Unix diff utility uses closely related techniques.
Line level vs word level
Line level runs one LCS pass over whole lines: fast and readable, but a one-word edit on a long line shows as "the whole line changed". Word level adds a second pass: changed line pairs are re-diffed token by token, so the highlight pinpoints exactly which words moved. Think of it as zooming in on the lines that the first pass flagged.
Typical uses
Reviewing code changes between two versions, comparing drafts of a document, spotting typos between two copies of text, or verifying that a config file change did exactly what you intended. The counters (lines added / lines removed) give a quick size estimate of the change before you read the details.

Frequently Asked Questions

What algorithm does the diff use?

The core is the classic longest common subsequence (LCS) algorithm. The two texts are split into lines, and LCS finds the largest set of lines that appear in both, in the same order. Lines in the original but not in the modified are removals; lines in the modified but not in the original are additions. Dynamic programming computes this in O(n·m) time.

What is the difference between line and word level?

Line level treats each whole line as one unit: if any character on a line changed, the entire line is marked as removed (red) and the replacement as added (green). Word level first aligns lines as usual, then re-diffs changed line pairs word by word with a second LCS pass, so you see exactly which words were inserted or deleted within a line.

Does it work with code?

Yes. Paste two versions of a function, a config file or a commit's before/after and the tool shows the changed lines. Word level is especially useful for code because it pins down the exact token that changed on an otherwise long line.

What do the colors mean?

Green background marks content that was added in the modified text; red background marks content that was removed from the original. Unchanged content has no background. The counters above the view show how many lines were added and removed.

Is my text sent anywhere?

No. Both texts and the entire LCS computation run as JavaScript in your browser tab. Nothing is uploaded, transmitted or stored — close the page and it is gone.

Reviewing a config file instead? Compare structure and values key by key with JSON Diff, or profile each version's writing with the Word Frequency Counter.