Difftastic compares files by parsing their syntax rather than diffing line by line. It is a CLI that highlights real code changes, including reflows across lines.
Overview
Difftastic is a command-line diff utility built around syntax-aware comparison. It parses source with tree-sitter and reports which syntactic pieces changed, showing them in side-by-side context so reviewers can see what moved versus what was merely reformatted.
When whitespace is only indentation or formatting, the tool can treat it differently from meaningful edits. If a formatter splits an expression across lines, the diff still reflects the underlying change instead of treating every new line as novel content. For unrecognized file extensions it falls back to a line-oriented diff with word highlighting.
It supports more than thirty programming languages plus formats such as JSON, YAML, HTML, and HCL, with a manual listing the full set. Git and Mercurial integration is documented, and it can read merge conflict markers to diff the two conflict sides in one file. A check mode compares abstract syntax without printing a full diff for faster change detection.
Output targets human review: it does not emit applyable patches, and it does not perform merges. Large files with many edits can be slow and memory-heavy, and parse errors cause a conservative fallback to line-based diffing.
Key features
- Tree-sitter syntax-aware diffs
- Side-by-side highlighted output
- Git and Mercurial integration
- Merge conflict marker support
- Fast same-AST check mode
- 30+ language parsers
- Word-level fallback for unknown types
- Real before and after line numbers
Use cases
- Reviewing formatted code changes
- Inspecting git diffs with structure
- Reading merge conflict changes
- CI syntactic change detection
- Comparing config files like JSON