Text Diff Checker

  • Free, no sign-up
  • Runs in your browser
  • Updated
Quick answer. The Text Diff Checker compares an original and a changed text and highlights additions and deletions by line, word or character, in a side-by-side or inline view, using the open-source diff library.

Text Diff Checker tool

Enter two texts to compare.

Runs in your browser. Your data never leaves your device.

How to use the Text Diff Checker

  1. 1Paste the original text on the left and the changed text on the right.
  2. 2Choose line, word or character comparison.
  3. 3Switch between side-by-side and inline views.
  4. 4Turn on ignore whitespace if spacing changes are not important.

What is a text diff checker?

A text diff checker compares two versions of a text and shows exactly what was added and what was removed. This tool highlights additions in green and deletions in red with a line through them, and lets you compare by line, by word or by character, in a side-by-side or inline view. An "ignore whitespace" option hides changes that are only spaces.

It is useful for checking edits to a contract, comparing two versions of code or config files, reviewing changes to an essay, or finding a typo between two lists that should be identical.

How does a diff work?

The tool uses the open-source jsdiff library (BSD licence), which implements the algorithm described by Eugene Myers in his 1986 paper "An O(ND) Difference Algorithm and Its Variations". The algorithm finds the shortest edit script: the smallest number of insertions and deletions that turn the original text into the changed one. The same idea powers git diff and most code review tools.

First, both texts are split into tokens. The choice of token is the "compare by" setting:

ModeTokenBest for
LinesEach lineCode, config files, lists, CSV
WordsEach word and the spaces betweenEssays, articles, contracts
CharactersEach characterSpotting single-letter typos, IDs, short strings

Then the algorithm finds the longest sequence of tokens the two texts have in common, and marks everything else as added or removed. A change is shown as a deletion of the old token followed by an addition of the new one.

Worked example

Original:

The meeting is on Monday at 10 am in Room 4.

Changed:

The meeting is on Tuesday at 10:30 am in Room 4.

In word mode the tool shows "Monday" deleted and "Tuesday" added, and "10" deleted and "10:30" added. Everything else is unchanged. In character mode it shows only the letters that differ: "Mon" replaced by "Tues" and ":30" added. The summary line reports how many characters were added and removed.

In line mode, the whole sentence would show as one deleted line and one added line, because the line changed. That's why line mode suits code and lists, while word mode suits prose.

When should I ignore whitespace?

Turn on Ignore whitespace when you care about content, not formatting. For example, when one version uses two spaces after full stops, or when code was re-indented. In line mode the option ignores changes in spaces within lines; in word mode it stops highlighting changes that are only spacing. Leave it off for Python, YAML or Makefiles, where indentation changes the meaning.

Tips

  1. Clean up first. If two lists are in a different order or contain repeats, run them through Remove Duplicate Lines with sorting on before comparing.
  2. Format JSON before comparing. Minified JSON is a single line. Pretty-print both versions with the JSON Formatter (try "Sort keys" too) so the diff shows the real change.
  3. Compare minified code carefully. After using the Code Minifier, compare the original source, not the minified output, which is hard to read.
  4. Check capitalisation changes separately. Use the Case Converter on both texts if you want to ignore case.
  5. Measure the size of an edit with the Word Counter on both versions.

Limitations

  • The tool shows what changed, not why, and it doesn't merge changes.
  • Moved paragraphs appear as a deletion in one place and an addition in another; the algorithm doesn't detect moves.
  • Very large texts in character mode can be slow, because the work grows with the number of differences. Use line mode for files over a few hundred kilobytes.
  • Rich formatting (bold, colours, tables from Word) is lost when you paste; only the plain text is compared.

Both texts stay in your browser. Nothing is uploaded, which makes this safe for private drafts and contracts.

Frequently asked questions

How does the comparison work?

It uses the diff library, which implements the Myers difference algorithm to find the smallest set of insertions and deletions that turns one text into the other.

Which mode should I use?

Line mode for code and lists, word mode for prose, and character mode for spotting single-letter typos.

Can I compare files?

Paste the contents of each file. Plain text, code, CSV and JSON all work.

Is it private?

Yes. Both texts stay in your browser and are never uploaded.

Last updated: . Written and tested by Abdul Moid Khan, ATechCraft. Read how we build and test tools.