Text compare (diff checker)

The text compare tool shows the differences between two versions of a text: added lines, removed lines, and words changed within a line, with the result as a unified diff.
Input
Up to 1,000,000 characters and 20,000 lines on each side. Text in any language is supported, including right-to-left text.
Comparison options
View
When ignoring whitespace changes, a run of spaces and tabs counts as one space, and spaces at the start and end of a line are not checked. When ignoring blank lines, blank lines are left out of the comparison and the result.

The comparison runs in the browser and requires JavaScript. A fixed example is shown.

Lines added: 3. Lines removed: 2. Lines unchanged: 2.
Comparison result
Original textNew text
1 Server: web1 1 Server: web1
2 Removed line Version 2.3 2 Added line Version 2.4
3 Removed line Memory: 2 GB 3 Added line Memory: 4 GB
4 Daily backup 4 Daily backup
5 Added line Monitoring 24/7
A common format for showing differences between files, with 3 lines of context around each change.

Everything runs in your browser; nothing is sent or stored.

  • Paste the previous version in the "Original text" field and the updated version in the "New text" field.
  • The result updates as you type, with the number of lines added, removed, and unchanged.
  • If needed, check the options to ignore whitespace changes, case differences, or blank lines.
  • Choose the "Side by side" or "Unified" view. Each change is shown with 3 unchanged lines around it, and the other lines are hidden.
  • Copy the result by clicking "Copy as unified diff".

How the comparison works

The comparison runs line by line and looks for the smallest number of changes that turns the original text into the new text, using the Myers algorithm, which common diff tools also use. A changed line is shown as a removed line and an added line, and in both lines the changed words, numbers, and symbols are highlighted. For example, in a change from "Version 2.3" to "Version 2.4", only the last digit is highlighted. When either line is longer than 2,000 characters, the changed words are not highlighted.

When to use the comparison options

Ignoring whitespace changes is useful for comparing code or a configuration file whose indentation changed, for example after switching from tabs to spaces. Ignoring case is useful for lists of domain names or email addresses. Ignoring blank lines is useful for text where blank lines were added or removed between paragraphs. A line that counts as identical thanks to one of the options is shown as unchanged, and in the "Side by side" view each side shows its own version.

The unified diff format

Unified diff is the standard format for showing changes in files. It is used by the diff -u command, by version control systems, and in patch files. The result starts with two header lines, --- original and +++ new, followed by sections called hunks. Each hunk starts with a line wrapped in @@ that gives the starting line and the number of lines of the hunk in each text. Within a hunk, a line that starts with - was removed, a line that starts with + was added, and a line that starts with a space did not change.

Reading a unified diff

  • @@ -1,4 +1,5 @@a hunk with 4 lines from the original text, starting at line 1, and 5 lines from the new text, starting at line 1.
  • @@ -9,4 +9,4 @@a hunk that starts at line 9 in both texts and has 4 lines in each text.
  • @@ -1 +1 @@a hunk of one line in each text. When a hunk has one line, the line count is left out.
  • @@ -0,0 +1,2 @@the original text is empty, and 2 lines were added in the new text.
  • @@ -1,2 +0,0 @@the 2 lines of the original text were removed, and the new text is empty.
  • -Version 2.3a line removed from the original text.
  • +Version 2.4a line added in the new text.

Text compare (diff checker) FAQ

Does the comparison treat Windows and Linux line endings the same?

Yes. The comparison does not show a difference between a CRLF line ending, common in Windows, and an LF line ending, common in Linux and macOS. Both count as the same line break. A line break at the end of the text does not count as an extra line either.

Why are two lines that look identical marked as different?

The difference usually comes from a character you cannot see: a space at the end of the line, a tab instead of spaces, a non-breaking space (NBSP), or a zero-width character. The "Ignore whitespace changes" option removes differences in spaces, tabs, and non-breaking spaces, but a zero-width character still counts as a difference. To find characters you cannot see, use the invisible character detector.

Why is a moved line shown as removed and added?

The comparison looks for the smallest number of changes and does not detect moved lines. A moved line is shown as a removed line in its previous position and as an added line in its new position.

Can I apply the result as a patch file?

Yes. You can apply the unified diff result to the original text with the patch command. The header lines contain the names original and new, so write the file name in the command itself, for example patch original.txt < changes.diff. When you compare with one of the ignore options, the differences the comparison ignored are not included in the result, so applying the result will not reproduce the new text exactly.

Can I compare long texts?

Yes. Each side accepts up to 1,000,000 characters and 20,000 lines. The view shows up to 2,000 lines, and the full result appears in the unified diff. A comparison that takes more than 4 seconds is stopped, usually when the texts are long and very different from each other.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement