Quick access

Saved in this browser. Sign in to keep it on all your devices.

Text Diff

Compare two texts and see the differences.

Original Text Left
Modified Text Right
Differences

Lines Added

Lines Removed

Lines Changed

Similarity

Quick Examples

Version 1.1 Updated What's new

Release notes

  1. v1.1 Latest
    • Added an in-depth guide below the tool, written from what the tool actually does.

About the Text Diff

The text diff tool compares two pieces of text and highlights exactly what changed, line by line, like a code review.

How to use it

  1. 1 Paste the original text on the left.
  2. 2 Paste the changed text on the right.
  3. 3 Review the highlighted additions and removals.

Frequently asked questions

Is my text uploaded?

No. The comparison runs in your browser.

Can I compare code?

Yes. It works with any plain text, including code, configuration files, and CSV.

Why are whole lines marked as changed?

The diff works line by line, so changing one word marks the whole line as changed. Look within the line to spot the exact edit.

Why does similarity say 0% when most lines match?

Similarity counts lines that match at the same line number. One line inserted near the top pushes everything below it out of position, so those lines stop counting even though their text is unchanged.

Can I compare Word or PDF files?

Not directly, because the boxes take plain text. Copy the text out of each document and paste it in. Formatting such as bold or font size is not compared.

Line 1 against line 1, line 2 against line 2

Most people expect a diff tool to work out which lines moved. This one is simpler. It walks down both boxes together and compares the lines that share a line number, after trimming spaces from each end. When a pair differs, it looks at whether the left line exists anywhere on the right and whether the right line exists anywhere on the left. A line found on the other side is treated as moved and is not reported. A line not found there is listed as removed or added.

That approach is fast and easy to reason about, and it does well when two versions have the same shape: a config file with a few edited values, a list with items added at the end, a paragraph-per-line document with some rewording. It gets less useful as lines shift around, and the examples further down show exactly how.

Reading the four counters

  • Lines Added: lines on the right whose text appears nowhere on the left.
  • Lines Removed: lines on the left whose text appears nowhere on the right.
  • Lines Changed: the smaller of those two numbers. It estimates how many additions and removals are really edits, and it overlaps with them, so do not add the three together.
  • Similarity: non-blank lines that match at the same position, divided by the line count of the longer text, rounded to a whole percent.

Blank lines do not count as matches. Two identical texts of "a", an empty line and "b" have two matching lines out of three, so the tool reports 67% for a pair with no differences at all. If you need to confirm that two texts are exactly the same, check that Added and Removed are both zero and that the Inline view shows no red or green.

A config file with three edits

The Config Update example on this page compares these two files:

port: 3000
debug: false
port: 8080
debug: true
timeout: 5000

The result is 3 added, 2 removed, 2 changed and 0% similarity, and the Unified view lists:

- port: 3000
+ port: 8080
- debug: false
+ debug: true
+ timeout: 5000

Here the counters tell the true story. Two values were edited, which is the 2 changed, and one setting is new, which explains why added is one higher than removed.

One new line at the top

Now try an insertion. On the left put a, b and c on three lines. On the right put new, a, b and c. Only one line was added, and the Unified view correctly shows just "+ new" with a count of 1 added and 0 removed. Similarity, however, reads 0%, because no line is at its old line number any more. The Inline view is noisier still, since it compares strictly by position and shows every line as replaced:

- a
+ new
- b
+ a
- c
+ b
+ c

So after an insertion or deletion near the top, trust the Added and Removed counts and ignore Similarity and Inline.

Two things the counts will not show you

Reordering is invisible to the counters. Compare a, b, c against c, b, a and you get 0 added and 0 removed, because every line exists on both sides. Unified shows only "b", the single line that stayed put, and the moved lines disappear from it. Inline does reveal the swap, so switch to it whenever order matters, as it does for a ranked list or a sequence of migration steps.

Indentation is the second blind spot. Side by Side and Unified trim each line before comparing, so a line indented by two extra spaces counts as unchanged and scores 100%. That is handy for prose. It is a trap for Python and YAML, where indentation carries meaning. Inline compares the raw lines and will flag it.

The Side by Side view also groups its output instead of aligning it. The left column lists removed lines first and unchanged lines after them, and the right column lists unchanged lines first and added lines after them, so a row in one column does not correspond to the same row in the other.

How version control solves this

Git and the Unix diff command look for the longest sequence of lines the two files share, so a line added at the top leaves everything else matched. The usual method is the O(ND) algorithm Eugene Myers published in 1986, and git diff also offers --patience and --histogram variants that often give more readable results on code. For word-level changes inside a line, use git diff --word-diff. To ignore whitespace, add -w.

Copy Diff on this page is not a patch. It copies both complete texts under "--- Original" and "+++ Modified" headings, which is convenient for pasting into a ticket, but the git apply and patch commands need the @@ hunk format and will not accept it. This page suits a quick look at two snippets you have in hand, without creating files or a repository. For reviewing code you will commit, let Git compare it.