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
- Lines prefixed with
+appear only in the modified version. - Lines prefixed with
-appear only in the original version. - Lines prefixed with a space are unchanged context lines.
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
- Spotting accidental whitespace changes in config files or JSON before committing.
- Comparing API responses across environments to find field drift.
- Reviewing AI-generated text edits against the original draft.
- Verifying that a minified/formatted roundtrip preserves content exactly.
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.