What unified diff actually shows you
Unified diff is the classic format: one column, lines prefixed with - for deletions and + for additions, with context lines unprefixed. It's what git diffproduces by default. It's compact: a 10-line change takes 10 lines plus context, not 20.
@@ -15,8 +15,9 @@ function validateUser(user) {
const errors = [];
- if (!user.email) {
- errors.push('Email required');
- }
+ if (!user.email || !isValidEmail(user.email)) {
+ errors.push('Valid email required');
+ }
+ if (!user.name) errors.push('Name required');
return errors;
}Unified diff is excellent for reading the narrative of a change: you see what was there, what replaced it, and the surrounding context in a linear flow. For terminal use, it's the only viable option — you can't display two columns in an 80-character terminal without degrading readability.
The weakness: for a line that changed by one word, you see two full lines (the old and new) and have to mentally diff them. For a function that moved, you see a deletion block followed (eventually) by an addition block, with no spatial relationship between them.
What side-by-side diff shows you
Side-by-side (split) diff puts the old version on the left and the new version on the right. Additions are visible only in the right column; deletions only in the left. Modified lines appear in both columns, aligned.
The key advantage is spatial alignment: you can visually scan a modified line and immediately see what changed. Your eye moves horizontally between the two columns rather than linearly through a sequence of +/- lines. For changes where most lines are modified rather than added or removed — like a refactor that renames variables throughout a function — side-by-side is dramatically easier to read.
The weakness: screen real estate. At 80 characters per column, you need 160+ characters of terminal or browser width. Longer lines wrap and become unreadable. And when a large block is added or deleted (no corresponding content on the other side), one column goes blank for many rows — wasted space that makes large additions harder to read than unified.
# Enable side-by-side diff in the terminal: # Install delta (modern pager with side-by-side support): # brew install git-delta / apt install git-delta git config --global core.pager "delta --side-by-side" git config --global delta.side-by-side true # Or use diff directly: diff -y --width=200 file_a.txt file_b.txt
How GitHub, GitLab, and VS Code make this choice
GitHub defaults to unified diff but offers a split view toggle. The split view is excellent for reviewing individual files in isolation — particularly for changed lines — but GitHub's implementation has a limitation: the split view doesn't handle added files gracefully (the entire left column is empty for new files).
GitLab behaves similarly, with the split view accessible via a button in the file header. GitLab's implementation is generally considered slightly better for large diffs because it virtualizes the DOM — it doesn't render thousands of diff lines at once.
VS Code's built-in diff viewer uses side-by-side by default (they call it "inline" toggle for the unified alternative). The VS Code approach is probably the best mainstream implementation: it offers word-level highlighting within changed lines and handles scrolling synchronization between columns well. The keyboard shortcut Alt+F5 / Shift+Alt+F5 navigates between change hunks.
# Open a diff in VS Code directly: git difftool --no-prompt --tool=vscode HEAD~1 # Configure as default difftool: git config --global diff.tool vscode git config --global difftool.vscode.cmd 'code --wait --diff $LOCAL $REMOTE'
The research: what actually helps reviewer performance?
Research on diff format and code review performance is frustratingly sparse. The most relevant studies tend to measure defect detection rates in code review generally, not the specific impact of diff format. What exists suggests that:
- Reviewers find defects faster with better tooling, but the effect is modest compared to factors like review preparation time and change size.
- Experienced reviewers are more adaptable — they perform similarly across formats.
- Less experienced reviewers show more sensitivity to format — side-by-side tends to help them more.
The honest answer is that the research doesn't settle the debate definitively. This is a domain where strong opinions are formed from individual experience and workflow, and those experiences are legitimately variable.
The opinionated take: match format to change type
Here is an opinionated framework based on the actual tradeoffs:
Use side-by-side for:refactors where many lines are modified (renames, restructuring), reviewing changes to complex logic where you need to compare old and new implementations directly, any situation where you need to understand "what was this before?" repeatedly.
Use unified for: terminal-based review (git diff), reviewing new files (no corresponding left column needed), reviewing deletions-only, any review where the change is primarily additions to a file that didn't change much.
The best tools make switching trivial. GitHub's toggle is one click. In the terminal, delta --side-by-sidecan be toggled with an alias. The habit to develop is not picking one format and using it always — it's reading the nature of the change first and choosing the format that will make that specific change most transparent.
Word-level diff: the format both sides should agree on
Both unified and side-by-side diff can be augmented with word-level highlighting — showing exactly which words within a modified line changed, rather than just marking the whole line as modified. This is arguably the single highest-impact improvement to diff readability available.
# Word-level diff with git: git diff --word-diff HEAD~1 # Word-diff with color only (no +/- markers): git diff --word-diff=color HEAD~1 # Delta (recommended pager) does word-diff automatically: # https://github.com/dandavison/delta git config --global core.pager delta git config --global delta.word-diff true
Word-level diff works well in unified format and eliminates one of the main advantages of side-by-side for modified-line review. If you add word-level highlighting to your unified diff setup, you'll find you need side-by-side less often — though not never.
Try it yourself
Diff Checker — compare two texts online →