Text Compare & Diff

How to use 3 steps
  1. Paste the Original and the Changed text.
  2. Choose Compare by and the View, plus the ignore options.
  3. Press Compare and read the highlighted changes.

Read the full guide

Differences

Differences are found with a longest-common-subsequence pass, the same approach diff uses, so unchanged text is matched as a block rather than character by character.

Loading the tool… 0 of 3 parts

Getting the tool ready. On a slow connection this can take a few seconds.

How this tool works

The two texts are split into tokens — lines, words or single characters — and compared by finding the longest sequence that appears in both, in the same order. Everything outside that sequence is an addition or a removal. This is how version-control tools compare files, and it is what makes the result readable: matching blocks stay put instead of every line after an inserted one being reported as changed.

Matching runs at the start and end of both texts are recognised and set aside before the comparison table is built, which on real documents removes most of the work, since edits are usually confined to part of a file. Ignoring case or surrounding whitespace changes what counts as a match; the text shown to you is always the original, so an ignored difference simply stops being highlighted rather than being rewritten.

Reading the comparison

  • An edited line is a removal plus an addition: at line granularity there is no concept of a modified line — the old one goes and the new one arrives. Switch to word granularity to see what actually changed inside it.
  • The counts are tokens, not edits: at word granularity a rewritten sentence can report a dozen additions. Compare the counts between runs rather than reading them as a number of changes.
  • Granularity is the main setting: lines for code and structured text, words for prose, characters for short strings where you are hunting a single wrong digit.
  • Character granularity is the expensive one: the comparison cost grows with the product of the two lengths, so a long document compared character by character will take noticeably longer than the same document compared by line.

Full guide

3 min read

Reading a diff: an edited line is a removal plus an addition

That is why one changed word reports as two changes. Why trailing spaces and Windows line endings make an unchanged file look rewritten, and why a moved paragraph is not detected as having moved.

Read the guide

Frequently Asked Questions

Specific to the Text Compare & Diff. Broader questions about this category are answered on the category page.

Line comparison has no modified state — the old line is a removal and the new one an addition. Word granularity shows the change within the line.
Words. Line comparison marks a whole paragraph as changed when one word moved, and character comparison is noisier than it is useful.
No. They only affect what counts as a match. What is displayed is always exactly what you pasted.
Its cost grows with the two lengths multiplied together. Comparing by line first and drilling into the changed part is much faster.
The texts differ, but only in ways you asked to ignore — case, or surrounding whitespace. Untick those options to see the differences.

Subscribe to receive notifications about new tools, features, and productivity tips.