How to use the text diff checker
- Paste the original text on the left and the changed text on the right. The comparison updates as you type.
- Read the coloured result: green lines with + were added, red lines with − were removed, grey lines are unchanged.
- Switch on Ignore whitespace to skip indentation and spacing changes, or Ignore case for case-insensitive comparison.
- Enable Hide unchanged lines to collapse long identical stretches, then copy or download the unified diff.
Features
- Myers diff algorithm, the same approach Git uses, so the result is a minimal set of changes
- Line numbers for both sides, added and removed counts, and an identical-text confirmation
- Ignore whitespace and ignore case options
- Collapse unchanged lines with three lines of context, like a code review
- Unified patch output that git apply and patch understand
- Handles up to 5,000 lines per side without leaving the browser
How the comparison works
Both texts are split into lines, then a shortest-edit-script search (Myers' algorithm in its linear-space form) finds the smallest number of insertions and deletions that turns the left text into the right one. A changed line therefore shows up as one removed line followed by one added line; there is no character-level highlighting inside a line, which keeps the result unambiguous for code, config files and logs.
Common leading and trailing lines are matched first, so pasting two long files that differ only in the middle is fast.
Reading a unified diff
The copied patch follows the unified format: a --- / +++ header, then hunks introduced by @@ -start,count +start,count @@ that give the line ranges on each side. Lines beginning with a space are context, - lines exist only in the original and + lines only in the changed text. You can save it as a .diff file and apply it with git apply or patch -p0.
Tips
When comparing JSON or code that was reformatted, turn on Ignore whitespace to see only the meaningful changes. For prose, comparing sentence-per-line text gives clearer results than long wrapped paragraphs, because a single edited word otherwise marks the whole paragraph as changed.