Text FIELD NOTES · 4 MIN READ
How a Word Diff Finds Every Changed Word
Inside the word-level diff: the longest common subsequence of words, inline additions and deletions, the wdiff convention, and what similarity really measures.
Change one word in a paragraph and a line diff condemns the entire line: it reports the whole sentence as deleted and an identical-looking sentence as added, leaving you to play spot-the-difference yourself. A word diff refuses to work at that grain. It slides down inside the line, finds the words that genuinely changed, and marks just those — the quick instead of two red-and-green paragraphs. The algorithm underneath is the same one version control uses; only the unit has changed.brown red fox
The shared spine: longest common subsequence
Both texts are split into words on whitespace, and then the tool finds the longest common subsequence (LCS) — the longest sequence of words that appears in both texts in the same order, with gaps allowed. That shared sequence is the spine of the comparison. Words on the spine are unchanged; the gaps between spine words are where edits happened, filled with deletions (words only in the first text) and additions (words only in the second):
A: the quick brown fox
B: the quick red fox
equal "the quick"
deleted "brown"
added "red"
equal "fox" summary: +1 -1, similarity 75%
The gaps-allowed part matters. Subsequence is not substring: words do not have to be adjacent in both texts to match, only in the same relative order. That is what lets the algorithm see through reordering-free edits and anchor on everything that survived.
Reading the segments
The output is flowing text, not a table: adjacent words of the same type merge, so the and quick appear as one unchanged segment, "the quick", and the edit reads naturally left to right. Deletions and additions sit in place, exactly where they occurred. The copy button emits the classic wdiff convention — deleted words wrapped in [- -], added words in {+ +} — the same plain-text format the old wdiff command-line utility popularized, which stays readable in email, tickets, and any editor:
The quick [-brown-] {+red+} fox
One honest caveat inherited from all LCS diffs: a moved word shows up as a deletion next to an addition, not as a "move". The tool reports what is provable from the text alone, and the pairing between a deletion and its neighboring addition is your interpretation, not a fact the algorithm asserted.
The similarity score
Next to the segments sits one number: twice the count of unchanged words, divided by the total word count of both texts. In the example above, 2 × 3 / 8 = 75%. Identical texts score 100%, texts sharing no words score 0%, and a single word swapped in a four-word sentence scores 75% — the same figure the segments already imply. It is a Dice-style overlap, and it answers "how much of this text survived?" rather than "where?", which makes it useful for spotting near-duplicate paragraphs at a glance. Tolerance knobs change the score too: with ignore case on, Hello world versus hello World matches every word and reports 100% — every word is compared by its normalized form, but the output still shows the original spelling.
Ignore punctuation, and the 4,000-word ceiling
The second knob, ignore punctuation, compares now! and now? as the same word by stripping leading and trailing punctuation before comparing — again displaying the originals. Tokens made entirely of punctuation become equal to each other rather than distinct symbols. Scale has a firm limit: 4,000 words per text, because the LCS table is built word by word in memory. Beyond that, a whole document comparison belongs in the line-level Text Diff tool, which scales to thousands of lines. Which raises the real question — when to diff by word and when by line? That choice deserves its own treatment, and gets one in Line Diff vs Word Diff. And when you do not need a map of changes at all, just a verdict, the Text Similarity Checker reduces the whole comparison to a single distance number.
Try it yourself
Paste the quick brown fox and the quick red fox into the Word Diff Checker and read the segments as flowing text, then copy the wdiff output and paste it into a plain-text editor to see the [- -] and {+ +} convention survive outside the page. Rewrite a sentence with one synonym swapped, note the similarity score, and then run the same two sentences through the line-level Text Diff tool to see why prose needs the finer grain.