Text Diff Checker

Compare two texts, code files, or documents side by side. Highlights every added, removed, and unchanged line — instantly, in your browser.

Paste Your Texts to Compare

Original / Text A
Modified / Text B

What Is a Text Diff?

A diff (short for "difference") is a comparison between two text inputs that highlights exactly what changed. The concept was invented in the early 1970s at Bell Labs as part of Unix development. Today, diff algorithms are the foundation of version control systems like Git, code review tools, and document comparison utilities. Lines prefixed with were removed, lines with + were added, and unmarked lines are unchanged context.

How the Diff Algorithm Works

This tool uses the Longest Common Subsequence (LCS) algorithm — the same algorithm behind git diff, the Unix diff command, and most code review platforms. LCS finds the longest sequence of lines common to both texts (in order, but not necessarily contiguous), then marks everything else as added or removed. This produces a minimal diff — the smallest set of changes needed to transform text A into text B.

The algorithm has a time complexity of O(n × m) where n and m are the number of lines in each input. For very large files (thousands of lines), optimised algorithms like Myers' diff (used by Git) improve performance, but LCS is accurate and practical for typical comparisons.

Diff View Modes

ModeDescriptionBest For
Side-by-SideOld and new text shown in parallel columnsCode review, seeing full context of both versions
Unified / InlineChanges shown in a single column with + and − markersQuick scanning, patch files, compact view
Word-levelHighlights individual word changes within linesDocument editing, catching small typos

Common Use Cases

Diff Options Explained

Understanding Diff Output

The unified diff format (used in patches and version control) adds context around each change. A typical hunk header looks like @@ -12,7 +12,8 @@, meaning the change starts at line 12 in both files, showing 7 lines from the old file and 8 from the new. Lines starting with - exist only in the old version, + only in the new, and lines with no prefix are unchanged context shared by both.

Diff in Version Control

Git uses diff extensively. Key Git diff commands include:

Tips for Clean Diffs

Frequently Asked Questions — Diff Checker

Written and reviewed by the FreeBytes Editorial Team · Last updated: June 2026