colordiff: Syntax-Colored diff Output
colordiff is a drop-in wrapper around diff that colors added lines green and removed lines red.
colordiff takes the same arguments as diff (it just adds color), or you can pipe any unified diff through it. It is a readability tool, not a different diff engine.
What it does
colordiff runs diff with your arguments and colorizes the output, or colorizes a diff piped into it on stdin. It uses the same exit codes as diff (0 identical, 1 differ, 2 trouble), so it can replace diff in scripts without changing behavior.
Common usage
colordiff -u old.txt new.txt
# colorize a diff produced by another tool
git diff | colordiff
diff -u a b | colordiffOptions
| Flag / usage | What it does |
|---|---|
| (diff flags) | All diff flags pass through (-u, -r, -w, etc.) |
| stdin pipe | Colorize a diff produced elsewhere |
| --color=yes | Force color even when not writing to a TTY |
| ~/.colordiffrc | Config file to customize the colors |
In CI
CI logs are not a TTY, so colordiff may disable color automatically; force it with colordiff --color=yes if your CI renders ANSI codes (GitHub Actions and GitLab do). Color helps humans read the failure but does not change the exit code, so gates still work.
Common errors in CI
"colordiff: command not found" means the package is not installed on the runner (apt-get install colordiff / brew install colordiff). Raw escape codes like ESC[31m showing as literal text in logs means the log viewer does not interpret ANSI; drop the color there. colordiff exits with diff's status, so a "failed" step is usually diff finding differences, not colordiff erroring.