How to use the diff checker

  1. Paste the original text on the left and the changed text on the right.
  2. The comparison updates automatically. Removed lines are shown in red with a minus sign, added lines in green with a plus sign, and unchanged lines without a color.
  3. The two number columns show each line's number in the original and the changed text.
  4. Use the options when needed. Ignore leading/trailing whitespace hides changes in indentation, Ignore case treats Hello and hello as equal, and Show changed lines only hides unchanged lines in long files.
  5. Use Swap to reverse the direction of the comparison.

How the comparison works

The tool finds the longest common subsequence of lines: the largest set of lines that appear in both texts in the same order. Every line that is not part of that sequence was either removed from the original or added in the changed version. This is the same basic approach used by the Unix diff command and by version control systems such as Git.

Because the comparison is line by line, a changed line appears as one removed line followed by one added line. Look at the pair to spot the exact edit.

What it is useful for

  • Code reviews when you do not have the changes in Git, such as code pasted in chat or email.
  • Configuration files, to see what changed between a working and a broken setup.
  • Contracts and documents, to check that only the agreed edits were made between two drafts.
  • API responses. Format both with the JSON Formatter and turn on Sort keys first, so that key order and spacing do not show up as differences.

Tips

  • If every line shows as changed, the two texts probably use different line endings or indentation. Turn on Ignore leading/trailing whitespace.
  • For prose, put each sentence on its own line before comparing. A small edit in a long paragraph then shows as one changed sentence instead of a whole changed paragraph.
  • Very large and very different files can be slow to compare in a browser. The tool compares up to about four million line pairs after removing the shared start and end, and asks you to split the text if it is larger.

Frequently asked questions

Is my text uploaded?

No. The comparison runs in your browser. This matters if you compare contracts, private code, or configuration with secrets. Even so, remove passwords and API keys from anything you paste into any website.

Can it compare word by word?

This version compares whole lines. To see word-level changes, put each word on its own line, for example by replacing spaces with line breaks using the Regex Tester replace field.