Text and file diff checker

Compare two texts or files, highlight changes and copy a unified diff.

Differences

Enter two texts to see what changed.

What this tool does

Paste an original text on the left and a changed version on the right, and the tool shows exactly what is different: which lines were added, which were removed, and, inside a line that was edited, which words changed. You can read the result side by side or as one inline list, ignore differences in whitespace or capital letters, and copy the whole comparison as a unified diff, the format that version-control systems and the patch command use.

It is meant for the everyday cases: two versions of a contract clause, an edited article, a configuration file before and after a change, a translation file, a snippet of code. Both texts stay in your browser, which matters when they contain private documents or credentials.

How to use it

  1. Put the original text in the left box and the changed text in the right box. You can also drop a text file onto a box, or use the "Open a file" button.
  2. Read the summary line: how many lines were added, removed and left alone. Identical texts say so.
  3. Switch between "Side by side" and "Inline". Added lines are green, removed lines are red, and the words that changed inside a line are highlighted more strongly.
  4. Tick "Ignore whitespace" to skip differences in spaces and indentation, or "Ignore upper and lower case" to treat capital and small letters as the same.
  5. Press "Copy unified diff" to copy the changes, or download them as a .diff file.

Long stretches of unchanged lines are folded into a button, so you see the changes with three lines of context around each one.

How the comparison works

The tool compares line by line using Myers' algorithm, the method behind the classic diff program: it finds the smallest set of added and removed lines that turns the first text into the second. Where a removed line and an added line sit in the same place, they are compared again word by word, so a change from price * 2 to price * 3 highlights only the 2 and the 3. If two lines share very little, they are shown as wholly different instead of as a noisy mix of highlights.

Line endings do not count as differences: a file with Windows line endings and a file with Unix line endings compare as equal if the text is the same. A missing line break at the very end of a text does not count either, so "delta" and "delta" followed by a line break read as the same line.

A worked example

Original:

timeout = 30
retries = 3
debug = false

Changed:

timeout = 60
retries = 3
debug = true
verbose = true

The result is three added lines, two removed lines and one line that stayed the same. As a unified diff it reads:

--- a/original
+++ b/changed
@@ -1,3 +1,4 @@
-timeout = 30
+timeout = 60
 retries = 3
-debug = false
+debug = true
+verbose = true

The marker @@ -1,3 +1,4 @@ means three lines of the original and four lines of the changed text starting at line 1. A minus marks a removed line, a plus an added one, and a space a line that is the same. Applying this diff to the original with the patch command gives back the changed text exactly.

Common mistakes

  • Comparing the wrong way round. Added and removed swap places if you put the new text on the left. Use "Swap sides" to flip them.
  • Reformatting hides the real change. If someone re-indented a whole file, turn on "Ignore whitespace" to see only what the words did.
  • Invisible differences. Two lines that look the same can differ by a trailing space, a tab or a different quotation mark. The highlighting shows them.
  • Pasting from a formatted document. Word processors replace straight quotes and add extra spaces; compare plain text to avoid false differences.

Limits

Each side can hold up to 5 million characters, and a file you open can be up to 5 MB. Large comparisons run in a background worker so the page stays responsive. If two texts differ in thousands of places, the tool cannot match them exactly line by line; it tells you, and shows the unmatched part as replaced. A very long result shows its first 3,000 rows, while the copied unified diff always contains everything.

Frequently asked questions

Are my texts or files uploaded?

No. The comparison runs in your browser. Files you open are read on your device and nothing is sent anywhere.

What is a unified diff?

A plain-text description of the changes between two files: a header with the two names, then hunks that start with a line like @@ -1,3 +1,4 @@ and list lines with a minus for removed, a plus for added and a space for unchanged. Git, the diff command and code review tools all use it.

Why are some words highlighted and others not?

When a removed line and an added line are in the same place, they are compared word by word and only the words that changed are highlighted. If they have too little in common the whole line is marked instead, which is easier to read.

Can it compare two Word or PDF files?

It compares text. Copy the text out of the documents and paste it in, or save them as plain text first. Binary files are refused.

Why does it say the texts differ in too many places?

Finding the smallest set of changes becomes very slow when two texts have almost nothing in common, so the tool stops at a limit and shows the unmatched part as replaced. Compare smaller sections to get an exact result.