A content-aware diff tool in Rust that compares code structurally with tree-sitter and also diffs pictures, fonts, archives and PDFs.
Wilfred/difftastic
A command-line diff tool that compares files by their syntax tree instead of lines, so reformatting and moved code show up accurately.
- Stars
- 26,159
- Forks
- 534
- Open issues
- 282
- Last commit
- 3 days ago
What is it?
Difftastic is a structural diff tool that compares two files based on their syntax rather than line by line. It parses both files, then highlights only the syntax elements that actually changed, even when code has been reformatted or split across more lines.
It treats whitespace as significant only where the language does, so a pure indentation change is recognised as such. For unrecognised file types it falls back to a line-oriented diff with word highlighting. Output is a side-by-side view designed for people to read, not for generating patches.
Difftastic works with git and other version control systems, and can resolve merge conflict markers by diffing the two sides. It also includes a check-only mode that exits with a status code depending on whether the syntax changed.
Key features
- 01Compares code by syntax tree, so reformatting does not produce noisy diffs.
- 02Supports over 30 programming languages.
- 03Highlights whitespace changes only where syntax makes them significant.
- 04Works with git and other version control systems.
- 05Diffs merge conflict markers by comparing the two conflicting sides.
- 06Offers a check-only mode to detect syntactic changes without a full diff.
Use cases
- Reviewing commits in which code was reformatted or restructured.
- Reading diffs of large refactors in languages like Rust, JavaScript, or HTML.
- Checking in CI whether two versions of a file differ syntactically.
- Inspecting merge conflicts side by side with a clearer view of the real changes.
Quick start
- 1
Install difftastic by following the Installation guide in the manual
- 2
Compare two files with difft
difft foo1.c foo2.c
Things to know
- Performance scales poorly on files with many changes and can use a lot of memory.
- It always treats order as significant, so reordered items such as set elements or unsorted keys show as changes.
- It does not perform merges or generate patches that can be applied later.
In collections
Topics
FAQ
- What is difftastic?
- A command-line diff tool that compares files by their syntax tree instead of lines, so reformatting and moved code show up accurately. Difftastic is a structural diff tool that compares two files based on their syntax rather than line by line. It parses both files, then highlights only the syntax elements that actually changed, even when code has been reformatted or split across more lines.
- Is difftastic free to use? What license does it have?
- difftastic is open source under the MIT license. Check the license terms before using it in commercial products.
- Is difftastic still maintained?
- Actively maintained. The last commit to difftastic was on Nov 4, 2026.
- What can I use difftastic for?
- Reviewing commits in which code was reformatted or restructured. Reading diffs of large refactors in languages like Rust, JavaScript, or HTML. Checking in CI whether two versions of a file differ syntactically. Inspecting merge conflicts side by side with a clearer view of the real changes.
- How do I install difftastic?
- Install difftastic by following the Installation guide in the manual Compare two files with difft: difft foo1.c foo2.c
- Where can I get difftastic?
- The source code and installation instructions are on GitHub: https://github.com/Wilfred/difftastic
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A syntax-highlighting pager for git, diff, grep and blame output, configured as a drop-in replacement for git's default pager.
Interactive terminal diff viewer for reviewing code changes from Git, Jujutsu, Sapling, GitHub PRs, and raw files, with inline agent notes.
A CLI tool that opens a local GitHub-style web viewer for reviewing git commit diffs, with comments you can copy as AI prompts.
A git pager that renders diffs side by side with syntax highlighting in the terminal, GitHub-style.
An agent Skill that turns Git changes into a one-screen HTML review page grouped by business purpose, instead of a file-by-file diff list.