What is a text diff?
A diff (difference) shows what changed between two versions of a text: which lines were added, removed, or stayed the same. The classic Unix diff command and Git's output are both based on the Longest Common Subsequence (LCS) algorithm, which finds the largest set of lines that appear in both texts in the same order. This tool implements the same LCS-based algorithm in pure JavaScript, supporting both line-level and word-level diffing with optional whitespace and case normalization.
How to use this tool
- 1 Paste the original text into the A panel and the modified text into the B panel.
- 2 The diff output updates live — green lines are additions, red are removals, plain text is unchanged.
- 3 Switch between Line diff and Word diff modes using the tab bar.
- 4 Toggle "Ignore whitespace" or "Ignore case" to focus on meaningful changes.
Frequently asked questions
What algorithm is used?
The classic Longest Common Subsequence (LCS) dynamic programming algorithm — the same approach used by the Unix diff utility and Git. It finds the minimum number of additions and deletions to transform A into B.
What is the difference between line diff and word diff?
Line diff treats each line as an atom — a line is either added, removed, or unchanged. Word diff splits on whitespace and diffs individual words, which is more useful for prose edits where only a few words in a line changed.
Is there a size limit?
The LCS algorithm is O(m×n) in memory and time. For inputs up to ~1000 lines or ~5000 words, it runs in milliseconds. Very large inputs (tens of thousands of lines) may be slow — for large diffs, use a dedicated tool like git diff or vimdiff.
What does "Ignore whitespace" do exactly?
It trims leading/trailing whitespace and collapses multiple spaces into one before comparing — so a line with two spaces between words matches one with one space. The output still shows the original text, not the normalized version.
Is my data sent anywhere?
No. Diffing runs entirely in your browser. Your text never leaves your device.