# Text Diff Checker

> 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.

URL: https://atechcraft.com/text-diff/
Category: Text Tools
Last updated: 2026-12-01
Author: Abdul Moid Khan, ATechCraft

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

## How to use the Text Diff Checker

1. Paste the original text on the left and the changed text on the right.
2. Choose line, word or character comparison.
3. Switch between side-by-side and inline views.
4. Turn 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](https://github.com/kpdecker/jsdiff) (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:

| Mode | Token | Best for |
| --- | --- | --- |
| Lines | Each line | Code, config files, lists, CSV |
| Words | Each word and the spaces between | Essays, articles, contracts |
| Characters | Each character | Spotting 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](https://atechcraft.com/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](https://atechcraft.com/json-formatter/) (try "Sort keys" too) so the diff shows the real change.
3. **Compare minified code carefully.** After using the [Code Minifier](https://atechcraft.com/code-minifier/), compare the original source, not the minified output, which is hard to read.
4. **Check capitalisation changes** separately. Use the [Case Converter](https://atechcraft.com/case-converter/) on both texts if you want to ignore case.
5. **Measure the size of an edit** with the [Word Counter](https://atechcraft.com/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.
