diff-so-fancy — Good-Looking Diffs for git and plain text
diff-so-fancy strips filenames, strips leading `+/-`, highlights word-level changes, and turns ugly unified diffs into clean, GitHub-style readable output — a drop-in replacement for git's default diff.
What it is
diff-so-fancy is a command-line tool that transforms ugly unified diffs into clean, human-readable output. It strips redundant filename headers, removes leading +/- characters, and highlights word-level changes within each line. The result looks like a GitHub-style diff in your terminal.
The tool targets any developer who reads diffs in the terminal. It works as a drop-in replacement for git's default diff pager with zero learning curve.
How it saves time or tokens
Reading standard unified diffs requires mental effort to parse +/- prefixes, track which file you are in, and spot the actual changed words within long lines. diff-so-fancy eliminates this overhead by highlighting only what changed at the word level. Reviewing pull requests and debugging commits becomes faster.
How to use
- Install diff-so-fancy via npm, brew, or your package manager.
- Configure git to use it as the default pager.
- Run git diff as usual — the output is automatically formatted.
# Install
npm install -g diff-so-fancy
# or
brew install diff-so-fancy
# Configure git to use diff-so-fancy
git config --global core.pager 'diff-so-fancy | less --tabs=4 -RFX'
git config --global interactive.diffFilter 'diff-so-fancy --patch'
# Now just use git diff normally
git diff
git log -p
git show HEAD
Example
# Standard git diff (hard to read):
- const MAX_RETRIES = 3;
+ const MAX_RETRIES = 5;
# diff-so-fancy output (word-level highlight):
# The line shows 'MAX_RETRIES = ' in normal color,
# '3' highlighted in red, '5' highlighted in green.
# No +/- prefixes. Clean file headers.
Related on TokRepo
- Featured workflows — Discover popular developer tool configurations on TokRepo
- AI coding tools — Tools that help review and understand code changes
Common pitfalls
- diff-so-fancy does not work well with git add -p (interactive staging) unless you also set interactive.diffFilter; without it, the patch mode shows raw diffs.
- Some terminal color schemes make the highlights hard to see; adjust diff-so-fancy's color settings or switch to a dark terminal theme.
- Piping diff-so-fancy output to other tools strips the ANSI colors; use --color=always if you need to pipe through grep or less.
Frequently Asked Questions
Yes. Once configured as the default pager, diff-so-fancy processes output from git diff, git log -p, git show, git stash show, and any command that produces diff output. It also works with plain diff commands outside of git.
They serve similar purposes. delta is an alternative diff highlighter with syntax-aware highlighting. You typically choose one as your git pager. If you prefer delta's features, use delta. diff-so-fancy is simpler and requires less configuration.
diff-so-fancy is available through Homebrew (brew install diff-so-fancy), apt (on Debian/Ubuntu), and as a standalone Perl script you can download directly. It has minimal dependencies — just Perl, which is pre-installed on most Unix systems.
No. diff-so-fancy only changes the visual presentation. The underlying diff data is identical. It strips visual noise like +/- prefixes and redundant headers but does not alter which lines are shown as added, removed, or changed.
Yes. diff-so-fancy respects git config color settings. You can configure colors for added lines, removed lines, changed words, and section headers through standard git config commands. The README documents all available color options.
Citations (3)
- diff-so-fancy GitHub— diff-so-fancy strips noise and highlights word-level changes in diffs
- Git Documentation— Git pager configuration for custom diff output
- GitHub Docs— Improving code review effectiveness through better diff visualization
Related on TokRepo
Discussion
Related Assets
Cucumber.js — BDD Testing with Plain Language Scenarios
Cucumber.js is a JavaScript implementation of Cucumber that runs automated tests written in Gherkin plain language.
WireMock — Flexible API Mocking for Java and Beyond
WireMock is an HTTP mock server for stubbing and verifying API calls in integration tests and development.
Google Benchmark — Microbenchmark Library for C++
Google Benchmark is a library for measuring and reporting the performance of C++ code with statistical rigor.