Skip to main content

Text Diff

Compare two pieces of text and highlight differences line-by-line, word-by-word, or character-by-character.

About this tool

Text Diff compares two pieces of text and highlights the differences line-by-line, word-by-word, or character-by-character. Drop your original text on the left and the modified version on the right — changes appear instantly.

Three granularities

  • Line — the best for comparing code files or any block-structured text. Added lines are green, removed lines are red.
  • Word — when only a few words change inside an otherwise-unchanged sentence; the algorithm spans whitespace properly so “the quick” vs “the slow” shows only the one swap.
  • Character — finer-grained, useful for typo detection. Operates on grapheme-units so combined characters don’t get split.

Algorithm

Behind the scenes is the classic Myers diff (1986) — an O(ND) algorithm where D is the edit distance. It’s the same algorithm used by diff on Unix, git diff, and most GUI merge tools. The full trace is computed on each keystroke in your browser; no network involved.

Normalize options

  • Ignore case — folds A-Z / a-z before diffing.
  • Ignore whitespace — collapses all whitespace runs to single spaces and trims. Indentation / trailing spaces will no longer count as differences.

Tips

  • Pasting a copy of a file you edited and the same file pre-edit gives a quick before/after diff. Try it with a git diff of an unstaged change.
  • Use the Swap button to flip the diff direction — lets you spot what was added vs. removed in either order.

Limits

  • For huge files (> 50k lines) the algorithm is still linear in edit distance, so very different inputs (one empty, one full text) can take a beat — but normal-sized edits are instant.
  • This tool does not auto-detect file types. If you paste JSON, you’ll see line-level changes only; choose a JSON-aware tool for structural diffs.

Privacy

Everything runs in your browser. Nothing is uploaded.