How to improve git diff readability with diff-so-fancy

Reading raw Git diffs can be tiring. Standard output is dense, often filled with pluses and minuses, and hard to scan quickly. If you review changes often, making diffs more readable can save time and help you spot issues faster.
In this article, we’ll show you how to improve Git diff readability using diff-so-fancy — a tool designed to make diffs easier on the eyes.
Key Takeaways
- diff-so-fancy improves Git diff readability with better formatting and colorization
- Installing and configuring it takes only a few steps
- Clear diffs make it easier to review changes accurately
Why Git diff readability matters
When you run git diff
, Git shows changes with symbols like +
and -
at the start of lines. While functional, it can be visually harsh, especially for large code changes.
Hard-to-read diffs can cause missed bugs, slower code reviews, and mental fatigue. Improving the way Git shows diffs is a small change with a big payoff in daily productivity.
Related reading: How to create and use Git aliases for faster workflow
What is diff-so-fancy?
diff-so-fancy is a small utility that takes Git diff output and formats it for better readability. It removes extra markers, highlights changes more clearly, and structures the output so that you can review code faster.
Key improvements:
- Clearer additions and deletions
- Emphasized changed words inside lines
- Cleaner hunk headers
- Easier-to-skim block grouping
How to install diff-so-fancy
You can install diff-so-fancy easily via common package managers.
On macOS with Homebrew:
brew install diff-so-fancy
On Ubuntu or Debian-based Linux:
sudo apt install diff-so-fancy
Or clone directly from GitHub:
git clone https://github.com/so-fancy/diff-so-fancy.git
Make sure diff-so-fancy
is in your system path after installation.
How to configure Git to use diff-so-fancy
Once installed, you need to tell Git to pipe diffs through diff-so-fancy.
Set it up with the following Git configuration commands:
git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"
git config --global interactive.diffFilter "diff-so-fancy --patch"
This setup:
- Pipes all diffs through diff-so-fancy
- Keeps color output intact
- Makes scrolling behavior in
less
clean and responsive
You can also create a Git alias if you prefer to call it manually. Example:
git config --global alias.dsf "!git diff --color | diff-so-fancy"
Now you can run git dsf
anytime to see a fancier diff.
Before and after: seeing the difference
Standard git diff
output:
- old line of code
+ new line of code
With diff-so-fancy:
- Only the changed parts of a line are highlighted
- File names and hunk headers are easier to scan
- Changes are structured in a way that follows your eyes naturally
This helps you quickly understand what changed, without extra noise.
Conclusion
Small improvements to your daily Git workflow add up over time. Configuring Git with diff-so-fancy makes your diffs easier to read, reviews faster, and mistakes less likely. If you liked this improvement, you might also find value in Using Git URL Shortcuts to Speed Up Repository Cloning.
FAQs
No. It only changes how diffs are displayed. Your Git history and data remain the same.
Yes. You can unset the Git config or call `git --no-pager diff` to bypass it temporarily.
It primarily improves `git diff` and `git log -p` outputs. Other commands remain unaffected.