Diff checker (compare two texts)

A diff lists the smallest set of lines added and removed to turn one text into another. Paste the original and the changed version to see each change line by line, with the changed words inside a line marked, all in your browser.

Spaces, tabs and indentation: runs of white space count as one space, and white space at the start and end of a line is ignored.

Treat capital and small letters as the same.

[-removed-] in the original line, {+added+} in the changed one.

Differences

2 changes

3 added, 2 removed, 3 unchanged lines

Differences, unified style

@@ -1,5 +1,6 @@
  Order #1042 for Priya
- Items: 2 masala dosa, [-1-] filter coffee
- Total: ₹[-240-]
+ Items: 2 masala dosa, {+2+} filter coffee
+ Total: ₹{+280+}
  Pay by: UPI
+ Note: ring the bell
  Deliver to: 12 MG Road, Bengaluru
Lines added
3
Lines removed
2
Lines unchanged
3
Lines in each text
5 → 6
Changed lines marked word by word
2[-removed-] and {+added+} inside the line
Where each change is, by line number
ChangeOriginal linesChanged linesLines
12–32–32 removed, 2 added
2none (after 4)51 added
  • In a pair of changed lines, [-…-] marks what was removed from the original line and {+…+} what was added in the changed one, the delimiters git diff --word-diff=plain uses. Pairs that share less than half their words are shown whole.

How does a diff checker find the differences?

A diff is the shortest list of lines to remove and add that turns one text into the other; everything else is the lines they have in common. Eugene Myers showed in 1986 that finding the longest common subsequence of two sequences and finding the shortest edit script are dual problems, and gave an algorithm that takes O(ND) time, where N is the total length of both texts and D the number of edits, so it is fast when the texts are similar.

This checker splits both texts into lines (or into words), gives each distinct line a number, trims the lines that match at the start and end, and runs Myers' algorithm with his linear-space refinement, which meets in the middle from both ends. Where removed and added lines sit together, the removed ones are listed first. When a removed line and an added line share at least half their words, they are compared again word by word, and the words that differ are wrapped in [-…-] in the removed line and {+…+} in the added one.

The output follows the unified format from GNU diff: lines common to both texts start with a space, removed lines with -, added lines with +, and each group starts with a hunk header such as @@ -2,3 +2,4 @@, meaning 3 lines from line 2 of the original and 4 from line 2 of the changed text. Like diff -u, it shows three unchanged lines around each change by default. It puts a space after each + and - and can mark words, so it is made for reading; to make a patch for the patch or git apply commands, run diff -u or git diff instead.

Line endings are ignored, so a Windows (CRLF) file compares cleanly with a Unix one, and a note says when they differ. Ignoring whitespace treats runs of spaces and tabs as one space and ignores them at the start and end of a line; ignoring case treats A and a as the same. Everything runs in your browser, and if two texts differ in so many places that comparing them would hang the page, it stops and asks you to compare a smaller part.

  unchanged line           (starts with two spaces)
- removed line             (only in the original)
+ added line               (only in the changed text)
@@ -2,3 +2,4 @@           3 lines from line 2 of the original, 4 from line 2 of the changed text
- Total: ₹[-240-]
+ Total: ₹{+280+}           [-…-] removed and {+…+} added inside a changed line

How do you read a diff?

A worked example, computed by this tool: the original “Pay by: UPI / Total: ₹240 / Deliver today / Leave at the door” against “Pay by: UPI / Total: ₹280 / Leave at the door / Ring the bell”
PrefixDiff lineOriginal lineChanged lineWhat it means
@@@@ -1,4 +1,4 @@1–41–4Hunk header: 4 lines from line 1 of the original, 4 from line 1 of the changed text
(space)Pay by: UPI11Unchanged
-Total: ₹[-240-]2—Removed from the original; [-…-] is the part that was removed
-Deliver today3—Removed from the original
+Total: ₹{+280+}—2Added in the changed text; {+…+} is the part that replaced it
(space)Leave at the door43Unchanged
+Ring the bell—4Added in the changed text

How to compare two texts and find the differences

  1. 1
    Paste both versionsPut the original in the first box and the changed version in the second, up to 200,000 characters each. Nothing is sent anywhere.
  2. 2
    Choose how to compareCompare by line for code, configuration and lists, or by word for prose and long lines. Tick the boxes to ignore whitespace or capital letters.
  3. 3
    Read the changesLines starting with - were removed and lines starting with + were added; inside a changed line, [-…-] and {+…+} show the exact words. The table gives the line numbers of every change.
  4. 4
    Copy or download the diffCopy the output or download it as changes.diff to share it or keep it with your notes.

Frequently asked questions

What do the + and - signs in a diff mean?
In the unified format that diff -u writes, and that git diff's patches are based on, a line starting with - is only in the original, a line starting with + is only in the new version, and a line starting with a space is in both. A header such as @@ -12,7 +12,8 @@ says the next lines cover 7 lines from line 12 of the original and 8 from line 12 of the new file.
What does [-old-]{+new+} mean in a diff?
It marks a change inside a line: the text between [- and -] was removed and the text between {+ and +} was added in its place. git diff --word-diff=plain uses the same delimiters, and git's documentation notes they aren't escaped, so text that already contains them can make the marks ambiguous.
Why does git diff sometimes show a change differently from another diff tool?
Two texts often have several edit scripts of the same, shortest length, and algorithms choose between them differently. git diff uses Myers' algorithm by default and also offers patience, histogram and minimal, which can match the lines up differently. Ties happen where the same line appears many times, such as a closing brace or a blank line; applying any of the diffs still gives the same final text.
How do I compare two texts while ignoring spaces or capital letters?
Tick “Ignore whitespace changes” and this checker treats lines that differ only in indentation, spacing or trailing spaces as the same; tick “Ignore case” for capital letters. It still shows the changed text's version of those lines, so you can see what is there, and says what it ignored.
Why does every line show up as changed when I compare two files?
Usually something invisible differs on every line: tabs instead of spaces, trailing spaces, or text that was reformatted, such as minified code against pretty-printed code. This checker already ignores Windows and Unix line endings; tick “Ignore whitespace changes” for the rest, or format both versions the same way before comparing.

Sources

Related tools

See all 73 free tools

Need a custom dev tool for your team?

We build internal tools, dashboards, APIs, and SaaS platforms. If you can describe it, we can ship it.

Built by CountryDevs · No signup · No ads · We count visits, never what you enter