Diff Checker

Paste two versions of a text to see every line that was added, removed or edited, with the changed words marked inside each edited line.

Runs entirely in your browser. Nothing you type or upload is sent to a server.

How a diff works

A diff answers one question: what is the smallest set of edits that turns the first text into the second? It works by finding the longest common subsequence, the largest set of lines that appear in both texts in the same order. Those lines are unchanged. Every line of the original that is not part of it was removed, and every line of the modified text that is not part of it was added.

This checker uses the algorithm Eugene Myers published in 1986, which is also what git uses by default. It finds a minimal edit script quickly when two texts are mostly the same, because it only explores as far as the number of differences requires. Where a removed line and an added line sit in the same spot and share enough words, they are shown as a single edited line, and the words are diffed a second time to mark exactly what changed inside it.

This is also why the result is better than comparing line 1 to line 1 and line 2 to line 2. Insert one line at the top of a document and a naive comparison reports every line below it as changed. A real diff reports one added line.

Reading the result

  • Red lines exist only in the original. Green lines exist only in the modified text. On an edited line, the darker highlight marks the words that differ.
  • Line numbers refer to each side separately, so after an insertion the right-hand numbers run ahead of the left.
  • Unchanged lines are folded away, keeping three lines of context around each change, the same amount git diff shows. Click a fold, or Show all lines, to expand.
  • Side by side is easiest for prose and short edits. Unified stacks the old and new versions of each line and reads better on a phone or for long lines.

The unified diff format

The unified view mirrors the format patches are written in. If someone sends you a patch file, it looks like this:

@@ -12,4 +12,5 @@
 function total(items) {
-  return items.reduce((a, b) => a + b);
+  if (items.length === 0) return 0;
+  return items.reduce((a, b) => a + b, 0);
 }

The header says the hunk starts at line 12 and covers 4 lines in the old file and 5 in the new. Lines starting with a minus were removed, a plus means added, and a space means unchanged context.

Getting a cleaner comparison

  • Formatting changes hide real ones. If one version was re-indented or had trailing spaces stripped, turn on Ignore whitespace so only the meaningful edits remain.
  • Normalize structured data first. Two JSON files with the same data in a different key order produce a noisy diff. Run both through the JSON formatter with sorted keys, then compare.
  • Prose diffs best one sentence per line. A paragraph is one long line, so a single comma marks the whole paragraph as edited. The word highlighting still shows where, but for heavy editing, a line break after each sentence gives a much clearer result.
  • Check what you are comparing. Text copied from a PDF often carries hard line breaks at the end of every printed line. Copy both versions the same way so those breaks match.

Frequently Asked Questions

How does the diff checker decide what changed?
It finds the longest sequence of lines the two texts have in common, in order, and reports everything else as added or removed. That is the smallest possible set of edits that turns the original into the modified text. Lines that were edited rather than replaced are then compared word by word, so you can see exactly which words differ.
Can I compare large files?
Yes. Texts tens of thousands of lines long compare in well under a second when they are mostly the same, which is the usual case. Two large texts with almost nothing in common take longer, so the comparison is capped at a few seconds. Past that it still shows every difference, but may mark a block as replaced instead of matching it line by line.
What does Ignore whitespace do?
It treats any run of spaces and tabs as a single space and ignores spaces at the start and end of a line, so a change in indentation or trailing spaces does not count as a difference. Line endings are always normalized, so a Windows file and a Mac or Linux file with the same text compare as identical.
Why does a moved paragraph show as removed and added?
A diff describes the fewest insertions and deletions between two texts, and a move is not one of those operations. Moving a block shows as a deletion in one place and an addition in another. Git and most code review tools behave the same way.
Can I compare Word documents or PDFs?
Copy the text out of each document and paste it into the two boxes. The comparison covers the words and line breaks, not fonts, styles or layout.
Does this work with code?
Yes. It uses the same family of algorithm as git diff, works on any programming language or config format, and the side-by-side view with line numbers matches what you see in a code review. For JSON, format both sides first so whitespace differences do not hide the real ones.
Is the text I compare uploaded anywhere?
No. The comparison runs entirely in your browser. Nothing you paste is sent to a server, which makes it safe for contracts, private code and configuration files.
The Internet Omni-Tool