Did something change between these two versions? Which lines were added or removed? Diff tools answer these questions instantly, essential for developers, writers, and anyone managing document versions.
What Is a Diff?
A diff (short for difference) shows what changed between two versions of text. It highlights:
- Added lines
- Removed lines
- Modified lines
- Unchanged context
Compare text with our diff checker.
How Diff Works
Diff algorithms find the Longest Common Subsequence (LCS) between two texts, then calculate the minimum changes needed to transform one into the other.
The result shows:
- Green/+ lines: Added (exists only in new version)
- Red/- lines: Removed (exists only in old version)
- White lines: Unchanged (same in both)
Common Use Cases
Code Review
Before merging code, reviewers examine diffs to understand what changed. This catches bugs, ensures quality, and shares knowledge.
Version Comparison
Compare document versions to see evolution over time. What did the editor change? Which sections were rewritten?
Configuration Changes
Before applying config updates, diff old and new versions to verify only intended changes are present.
Contract and Legal Review
Compare contract versions to ensure no unauthorized changes were made.
Debugging
When code breaks, diff the working and broken versions to find what changed.
Types of Diff Views
Side-by-Side
Old version on left, new on right. Easy to compare visually but uses more space.
Unified (Inline)
Both versions in one stream. - lines are removed, + lines are added. Common in terminals and patches.
Character-Level
Highlights exact characters that changed within a line, not just whole lines.
Reading Unified Diff Format
@@ -3,7 +3,7 @@
unchanged line
another unchanged line
-this line was removed
+this line was added
more context
@@marks a change section (hunk)-3,7means starting at line 3 in old file, 7 lines of context+3,7means starting at line 3 in new file- Lines starting with space are unchanged context
Diff in Version Control
Git Commands
# See unstaged changes
git diff
# See staged changes
git diff --staged
# Compare branches
git diff main..feature-branch
# Compare specific commits
git diff abc123 def456
Pull Request Diffs
GitHub, GitLab, and Bitbucket show diffs for every pull request, making code review collaborative.
Beyond Text Comparison
Image Diff
Visual comparison tools overlay images to show pixel differences. Useful for design changes.
Binary Diff
Specialized tools compare binary files byte-by-byte for non-text content.
Directory Diff
Compare entire folder structures to find added, removed, or changed files.
Best Practices
- Review diffs carefully: Don't just skim—understand each change
- Use meaningful context: Some diff tools show too little surrounding code
- Check for whitespace: Sometimes diffs show changes that are just formatting
- Ignore generated files: Auto-generated code creates noisy diffs
- Small, focused changes: Large diffs are harder to review
Whitespace and Formatting
Sometimes diffs show changes that are just:
- Trailing whitespace added/removed
- Tabs vs. spaces
- Line ending differences (LF vs. CRLF)
Most diff tools can ignore whitespace changes with flags like -w or --ignore-all-space.
Related Tools
- Diff Checker - Compare text online
- Find and Replace - Make bulk changes
- Remove Duplicates - Clean up text
Our diff checker provides instant, visual comparison between any two texts—no installation required.