Line-based diffs get confused by things that don't actually change meaning: reflowing a function's arguments across lines, reindenting a block, or wrapping code in a new condition lights up a diff even when the logic is identical. Difftastic diffs differently. It parses both versions into syntax trees and compares those, so it reports what structurally changed - and stays quiet about reformatting that a line diff would flag as a wall of red and green.
Structural, Not Line-Based
Because it understands the language, moving an argument onto its own line shows as no real change, while a genuine logic edit stands out clearly. You can run it standalone or wire it in as git's external diff tool:
# Diff two files directly
difft old.py new.py
# Use it for git diffs
GIT_EXTERNAL_DIFF=difft git diff
Many Languages
Difftastic ships parsers for a wide range of languages, so the structural treatment applies across most of what you work in. When a change is purely cosmetic, it tells you; when it's real, it highlights exactly the changed nodes.
Rough Edges and Limitations
- Parser-dependent. Unsupported or unusual syntax falls back to a simpler diff.
- Different, not always better. For tiny textual changes, a classic line diff can be clearer.
- Heavier on huge files. Parsing costs more than line-diffing on very large inputs.
For reviewing changes where formatting churn hides the real edit, Difftastic cuts straight to what actually changed.
Internal link suggestion: link "git's external diff tool" to the delta post, the line-based-but-beautiful alternative.