Text diff

Compare two texts and see what changed.

loading Text diff
About this tool

What is a text compare tool?

A text compare tool (also called a diff checker or text difference tool) puts two versions of a text side by side and highlights what changed: lines that were added, removed or modified. The same idea sits behind git diff, code review and the "track changes" feature of word processors. Use it to see what an editor changed in your article, to compare two config files, to check that a copy-and-paste did not alter anything, to review a contract revision or to find the line that breaks a deployment.

This online diff checker shows the original on the left and the modified text on the right, with the changed lines coloured. It runs the same diff editor engine used by Visual Studio Code, entirely in your browser: nothing you paste is uploaded, which matters when the text is a contract, a log with customer data or a .env file. You can switch between a side-by-side view and a unified (inline) view, ignore whitespace changes, wrap long lines, jump from one difference to the next and swap the two sides.

The tool compares line by line and then highlights the exact characters that changed inside a modified line, so a one-letter typo is easy to spot even in a long paragraph. It counts the lines added and removed and the number of separate blocks that differ.

How to compare two texts

  1. Paste the original text in the left editor and the changed text in the right one. A shopping-list example is loaded at first; clear it or use the load example button to get it back.
  2. Read the highlighted result: green for added lines, red for removed lines, with the changed characters marked inside modified lines.
  3. Use the previous and next difference buttons to jump between the blocks. The counter shows how many blocks differ.
  4. Choose the view: automatic (side by side on a wide screen, unified on a phone), side by side, or unified.
  5. Turn on "ignore whitespace" when indentation or trailing spaces are noise, and "word wrap" for long lines.
  6. Use "swap sides" to reverse which text is the original, and clear to start over.

Examples

A shopping list

Original:

Shopping list
- milk
- bread
- eggs
- coffee

Modified:

Shopping list
- oat milk
- bread
- eggs
- tea
- apples

The diff shows - milk replaced by - oat milk, and - coffee replaced by - tea plus the new line - apples: two blocks, two lines removed and three added. The same comparison in unified format is:

@@ -1,5 +1,6 @@
 Shopping list
-- milk
+- oat milk
 - bread
 - eggs
-- coffee
+- tea
+- apples

Whitespace only

Two files that differ only by trailing spaces show many differences until you turn on ignore whitespace; then the result is empty and you know the content is the same.

A configuration change

Compare yesterday's and today's nginx.conf to find the single proxy_read_timeout value that changed among hundreds of lines.

A one-letter typo

In Recieve the invoice versus Receive the invoice, the line is marked modified and the swapped letters are highlighted inside it.

Common mistakes

  • Comparing different line endings. A file saved with Windows endings (CRLF) can look different from one with Unix endings (LF). Paste as plain text and ignore whitespace if needed.
  • Pasting rich text from a word processor. Smart quotes, non-breaking spaces and different dashes appear as changes. They are real differences in the characters.
  • Expecting a moved paragraph to be shown as moved. A diff reports it as removed in one place and added in another.
  • Mixing up the sides. The left is the original and the right the new version; use swap sides if you pasted them the other way round.
  • Comparing huge files in a phone browser. Very large inputs can be slow; compare in parts or use a desktop.
  • Comparing structured data as text. For JSON, key order and formatting create noise; use the JSON diff to compare by structure.

Frequently asked questions

How do I compare two texts online for free?

Paste one in each editor. The differences are highlighted immediately, and nothing is uploaded or registered.

Is it safe to compare confidential text?

The comparison runs in your browser and nothing is sent to a server.

How do I ignore case or whitespace?

Use the ignore whitespace option. To ignore case, convert both texts to lower case first, for example with the case converter.

What is the difference between side-by-side and unified?

Side by side shows two columns; unified shows one column with - and + lines, like git diff.

Can I compare lists of lines more easily?

Sort and deduplicate them first with the line tools, then compare.

How to compare texts in code

Bash

diff -u a.txt b.txt

Python

import difflib

a = "Shopping list\n- milk\n- bread\n".splitlines(keepends=True)
b = "Shopping list\n- oat milk\n- bread\n".splitlines(keepends=True)
print("".join(difflib.unified_diff(a, b, "a.txt", "b.txt")))
Report a problem