Text Diff Checker - Compare Two Texts Online

Compare two blocks of text side by side and see differences highlighted. Identify additions, deletions, and modifications instantly.

How Diff Works

A diff algorithm compares two texts and produces the shortest sequence of edits — insertions and deletions — needed to transform one into the other. The most widely used algorithm is Myers diff (published 1986), which powers Git, GitHub, and most modern diff tools.

Standard diff output uses a unified format:

Common Use Cases

Diff in the Terminal

Unix diff command

# Basic line diff
diff original.txt modified.txt

# Unified format (what Git uses)
diff -u original.txt modified.txt

# Side-by-side comparison
diff -y original.txt modified.txt

# Ignore whitespace
diff -w original.txt modified.txt

Git diff

# Show unstaged changes
git diff

# Compare two branches
git diff main..feature-branch

# Compare specific files between commits
git diff HEAD~1 HEAD -- path/to/file.ts

# Word-level diff (highlight changed words, not lines)
git diff --word-diff

Reading a Diff — Example

@@ -1,5 +1,6 @@
 function greet(name) {
-  return "Hello " + name;
+  return `Hello, ${name}!`;
+  // Updated to use template literals
 }

The @@ line shows the position: lines 1–5 in the original (-1,5), lines 1–6 in the new version (+1,6). The red line was removed, the two green lines were added.

Tips for Effective Diffing

Frequently Asked Questions

What is a diff and how does it work?

A diff shows what changed between two versions of text. The Myers algorithm finds the shortest edit script — the minimum insertions and deletions to transform one text into the other. Added lines appear in green, removed lines in red. Unchanged lines are shown as context.

What are common uses for a text diff tool?

Diff tools are used for: comparing code before and after a change, reviewing config file differences between environments, verifying refactoring produced no unintended changes, comparing API responses, and spotting differences between two versions of any document.

What is the difference between line diff and character diff?

Line diff compares entire lines — a changed line shows as a deletion and addition pair. Character (inline) diff highlights the exact characters that changed within a modified line, making it easier to spot small typos or single-value changes in long lines.

Related Hash & Data Tools