Comparing two pieces of text to find what changed is something developers do daily with git diff. But you don’t need a terminal or a code editor — a browser-based diff tool works just as well for any text.
What is a text diff?
A diff (short for “difference”) compares two texts and highlights what was added, removed, or changed. It’s the same concept behind version control systems like Git.
Common use cases
Code review
Compare two versions of code to see exactly what changed. Useful when you don’t have access to a git repository or need to compare snippets quickly.
Writing and editing
Compare drafts of an article, email, or document. See what your editor changed, what was added, and what was removed.
Configuration files
Spot differences between development, staging, and production configs. A single changed value can cause bugs — diffing makes it obvious.
Data comparison
Compare CSV exports, JSON responses, or log files to find discrepancies.
Contract review
Compare versions of a contract or legal document to see what was modified between revisions.
How diff algorithms work
Most diff tools use a variant of the Longest Common Subsequence (LCS) algorithm:
- Find the longest sequence of characters or lines that appear in both texts
- Everything not in the common subsequence is either an addition or deletion
- Display additions (usually in green) and deletions (usually in red)
Line-level vs character-level
- Line-level diff — Compares line by line. A single character change marks the entire line as modified. Better for code and structured text
- Character-level diff — Highlights exactly which characters changed within each line. Better for prose and short texts
Tips for effective comparison
- Normalize whitespace — Trailing spaces and different line endings (LF vs CRLF) can create false diffs
- Sort first if order doesn’t matter — Comparing unordered lists? Sort both sides first
- Use side-by-side view for long texts, inline view for short comparisons
- Copy-paste carefully — Hidden characters (zero-width spaces, non-breaking spaces) can cause unexpected diffs