Skip to content

Diff Checker

Compare two texts and highlight additions, removals and changes line by line

Original Text
Changed Text
Differences

Paste two texts above and click Compare

Free Diff Checker — Compare Texts Online

Our Diff Checker helps you compare two versions of text, code, or documents and see exactly what changed. Additions are highlighted in green, removals in red. Line numbers make it easy to locate specific changes. Works with code files, configuration changes, document revisions, and any plain text.

Powered by a pure JavaScript diff algorithm — all comparison happens in your browser. No text is sent to any server, making this safe for confidential code and sensitive documents.

Last Updated: April 2026

Frequently Asked Questions

A diff checker compares two texts and outputs the differences. Lines that exist only in the original are marked as removed (red). Lines that exist only in the changed version are marked as added (green). Lines present in both are shown unchanged. This is the same algorithm used by git diff, SVN, and other version control systems.

Yes. The diff checker treats any text as plain text — it works equally well with source code, configuration files, markdown, SQL, and prose. Just paste the two versions into the input boxes.

Completely. All comparison happens in your browser using JavaScript. Nothing is transmitted to our servers. You can safely paste confidential code, database queries, and sensitive configurations.

Line diff compares entire lines — a line is either added, removed, or unchanged. Word diff highlights individual words within changed lines, showing more granular changes. Use line diff for code and word diff for prose documents where paragraphs change slightly.

How to Use a Diff Checker to Compare Two Texts Accurately

A diff checker compares an original text with a changed one and marks what was added, removed or left alone. It works by finding the longest run of lines the two versions share, then flagging everything outside that run as a change. This guide shows how to read the result, which mode to pick, and why some diffs look noisier than they should.

Compare Two Texts in Five Steps

  1. Paste the older version into Original Text and the newer version into Changed Text.
  2. Pick a mode: Line by line for code, config and logs, or Word level for prose and single-line strings.
  3. Click Compare. The panel shows added lines in green and removed lines in red, with a count of each.
  4. If you pasted them in the wrong order, press Swap Texts and compare again. Additions and removals trade places.
  5. Scan the red and green blocks first, then read the unchanged lines around them for context.

Tip: This tool compares text exactly as typed. A trailing space, a tab instead of spaces or a Windows line ending (\r\n) will show up as a change. If you only care about meaning, normalise whitespace in both boxes before you compare.

How the Comparison Works

Diff tools solve a classic problem: the longest common subsequence (LCS). Given two lists of lines, find the longest sequence that appears in both in the same order. Lines in that sequence are "unchanged". Lines only in the original are "removed". Lines only in the new text are "added".

Eugene Myers published the algorithm most tools descend from in 1986, in An O(ND) Difference Algorithm and Its Variations. Its cost grows with the number of differences, not with the size of the files, so two nearly identical files compare quickly. Git uses a variant of it, as the git diff documentation describes.

Because several different edit scripts can describe the same change, two diff tools may show slightly different results for the same pair of files. Both are correct if they transform the original into the new text.

Worked Example: Spotting a Config Change

Say a deploy broke and you suspect a config edit. Paste both versions:

// Original
timeout = 30
retries = 3
host = db1.internal
log_level = info

// Changed
timeout = 30
retries = 5
host = db1.internal
log_level = debug
cache = on

In line-by-line mode the result reads like this:

  timeout = 30
- retries = 3
+ retries = 5
  host = db1.internal
- log_level = info
+ log_level = debug
+ cache = on

Two lines were modified (each shows as one removal plus one addition) and one line was added. That is 3 additions and 2 removals. Nothing else moved, so you know exactly where to look.

Line Mode vs Word Mode

SituationBest modeWhy
Source code, config, CSV, logsLine by lineThese formats are organised in lines, so a changed line is the natural unit.
A paragraph with one edited phraseWord levelLine mode would mark the whole paragraph as replaced.
Minified JSON or a long single-line stringWord levelThere is only one line, so line mode gives you "everything changed".
Two contracts or essaysWord levelShows the exact words that were inserted or deleted.

If you are comparing minified JSON, run both sides through the JSON formatter first. Pretty-printing puts each key on its own line, and line mode then pinpoints the changed field.

Reading Unified Diff Notation

You will often meet diffs in pull requests and patch files. The format is described in the GNU diffutils manual. A few symbols cover most of what you need:

SymbolMeaning
- at the start of a lineLine exists only in the original
+ at the start of a lineLine exists only in the new version
A space at the startUnchanged context line
@@ -4,6 +4,7 @@Hunk header: starting at line 4, 6 old lines became 7 new lines

The color-coded view above is the same information, only easier on the eyes.

Why a Diff Can Look Noisier Than the Real Change

  • Line endings. A file saved on Windows (\r\n) against one saved on Linux (\n) can make every line differ. Convert one to match the other.
  • Tabs vs spaces. A re-indented block appears as fully rewritten even though no logic changed.
  • Trailing whitespace. Invisible, but it is a real character difference.
  • Moved blocks. Diff algorithms do not track moves. A function moved to another place shows as one removal and one addition.
  • Reformatting. If one side went through a formatter, run both through the code beautifier with identical settings, then diff.

Practical Uses

  • Code review without Git. Compare a snippet from an email or chat against your local copy.
  • Debugging environment drift. Paste the .env or config from staging and production and see what differs.
  • Checking edits. Compare a draft before and after an editor's pass.
  • Verifying copies. Confirm that a pasted block matches the source after you cleaned it up. For files, you can also compare SHA-256 hashes: identical hashes mean identical bytes.
  • Spotting hidden changes in legal or policy text. Word mode finds a single changed "may" to "shall".

Privacy note: Both texts stay in your browser tab. The comparison runs in JavaScript on your device, and nothing is sent to a server. Even so, avoid pasting live secrets on shared computers, and clear the boxes when you are done.

A Practical Method for Reviewing a Diff

Reading a diff well is a skill. Most missed bugs come from skimming the green lines and ignoring what was removed. Use this routine for every comparison, whether it is ten lines or a thousand.

  1. Read the removals first. A deleted line is a behavior you no longer have. Ask whether that was intended.
  2. Read the additions second. Check each one against the removal it replaced, if any. A red line directly followed by a green line is an edit, so compare the pair character by character.
  3. Look at what did not change. If you expected a related line to change and it did not, the edit may be incomplete, such as a renamed variable that still appears unchanged elsewhere.
  4. Count the changes. A small change count with a big visual impact often means whitespace. A large count for a one-line edit means line endings or indentation changed.

Diffing structured data

Comparing CSV exports, JSON responses or SQL dumps works best when both sides are sorted and formatted the same way. Sort the rows first, then compare. The CSV viewer helps you inspect the columns before you diff them. If two exports differ only in row order, an unsorted diff shows a mess even though the data is the same.

Diffing prose

Word mode is useful for editors and lawyers, but it can feel busy when sentences were reorganised. In that case, compare paragraph by paragraph. Copy one paragraph from each version into the two boxes and run the comparison, so the highlights stay meaningful.

Rule of thumb: if a diff has more changed lines than you expect, normalise first and re-run. A clean diff is a short one.

More questions

Why does my diff show every line as changed?

Almost always a line-ending or indentation difference. One file uses Windows \r\n endings and the other uses \n, or one uses tabs and the other spaces. Normalise both sides and compare again.

Can this tool ignore whitespace or letter case?

No. It compares the exact characters you paste. To ignore case, convert both texts with the text case converter first. To ignore line breaks, strip them from both sides.

Does the order of the two boxes matter?

Yes. The left box is the "before" and the right is the "after". Swapping them turns every addition into a removal and vice versa. The overall set of differences is the same.

How is a diff checker different from Git diff?

Git diff works on tracked files and commits and can follow renames. A browser diff checker works on any two pieces of text you paste, with no repository needed. The comparison idea is the same.

Why does a moved paragraph show as deleted and re-added?

Standard diff algorithms look for the longest shared sequence in order. They have no concept of "moved". A block that changes position cannot be part of that sequence, so it appears in both places.

Can I compare very long documents?

Yes, within your browser's memory. Line mode stays fast for thousands of lines. If a very large pair feels slow, compare it in sections.