Text diff
Compare two texts line by line or word by word, with a unified diff (+/-/context) and added/removed/unchanged counts. Ignore case, whitespace and blank lines as needed.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Diff options
Diff result
Line mode prefixes each line with two spaces (unchanged), - (removed) or + (added); word mode marks inline changes as [-removed-] and {+added+}.
Type text on both sides to start comparing
What this tool does
- Compare two config files, two versions of copy or two SQL statements to see exactly which lines changed.
- Use word granularity for inline changes: when a few characters differ, the whole line is not reported as a delete plus an add.
- While proofreading translations or manuscripts, switch on "Ignore whitespace" and "Ignore blank lines" to focus on real wording changes.
- Debug strings that look identical but compare unequal: if they still differ with case ignored, there is an invisible character or a punctuation difference.
Example
Input
Left: alpha↵beta↵gamma Right: alpha↵beta changed↵gamma↵delta (by line)
Output
alpha - beta + beta changed gamma + delta
Unchanged lines are prefixed with two spaces, removals with "- " and additions with "+ ". The stats are 2 added, 1 removed, 2 unchanged. Word mode on "The quick brown fox" vs "The quick red fox jumps" gives The quick [-brown-] {+red+} fox {+jumps+}.
Frequently asked questions
What is the difference between word mode and line mode?
Line mode compares line by line and emits the unified diff +/- prefixes, which is best for structural changes. Word mode splits both texts into words (Chinese is split per character) and emits [-removed-] and {+added+} inline markers, which is best for spotting which few characters changed in a sentence. Word mode gives no line numbers, so it gets hard to read when the change is large.
Why does a large text hit the size limit?
The algorithm builds an LCS (longest common subsequence) table, so time and memory grow with the product of the two line counts. To keep the browser responsive the tool refuses to compute once that product exceeds four million cells. Split the text into smaller chunks and compare them separately.
What do "ignore whitespace" and "ignore blank lines" each do?
"Ignore whitespace" treats runs of whitespace as a single space and trims the ends of each line, removing false differences caused by indentation or stray spaces. "Ignore blank lines" only applies in line mode and drops blank lines entirely, which is handy when code blocks differ only in spacing.
The texts are identical but it still shows a pile of lines.
That means they are identical only under the current options — with "Ignore case" on, Hello and hello count as unchanged, and the output shows the left-hand spelling. Turn the option off to see the real difference.
Is the comparison saved or uploaded?
No. The diff is computed in the browser with plain JavaScript; there are no network requests and everything is gone on refresh.
Keywords:text diffdiff文本对比文本差异compare text统一 diffunified diffLCS代码对比