' + '

Text Diff

Compare two blocks of text line by line

How Text Diff Works

A diff compares two texts line by line and shows what was added, removed, or unchanged. The standard algorithm is the Longest Common Subsequence (LCS): it finds the largest set of lines that appear in the same order in both texts, then marks everything outside that set as either added (+) or deleted (-).

Reading the Output

Unified vs. Split Diff

This tool displays a split diff (original on the left, modified on the right), which makes it easier to read rewrites side by side. Command-line tools like diff and git diff default to a unified diff format where added and removed lines are interleaved with context. Both formats convey the same information.

Common Uses

Limitations

Line-based diff is not well-suited for comparing binary content, heavily reformatted code (e.g., indentation changes make every line look different), or prose where rewrites span multiple sentences. For code, a semantic diff that understands the language's AST is more useful than a raw line diff.