I review diff tools by asking one question: when the code changed what it does, did the tool say so? Not “did it look nice”. Did it notice. difftastic (the binary is difft) is the diff that parses your code with tree-sitter before comparing it, so it can tell a real change from a reformat. Your colleague ran a formatter over the whole file, git diff shows 400 red and green lines, and difftastic shows you the two tokens that actually changed. Most of the time that’s exactly what you want.
Most of the time. In Python, where four spaces of indentation decide which block a line belongs to, I found a case where difftastic parses both files, decides they’re different, and then prints No syntactic changes. and exits 0. I generated 1,000 random cases and it did that 190 times. The maintainer has known about it since October 2023. It’s a real bug, and it’s the most important paragraph in this review, so it’s the first surprise below.
The verdict, up front: use it for reading diffs. It’s very good at that, and it’s honest about when it gives up and falls back to plain text. Don’t use it as a gate. Don’t make its exit code, or its “no changes” message, the thing that decides whether a human looks at a change. It survives a normal Tuesday. On a bad Tuesday, someone reviews a Python PR with it, and their eyes slide right past the line that just started deleting every file in the directory.
Everything below ran on Ubuntu 26.04.1 LTS (x86_64) with the official release binary. Ubuntu’s apt has no difftastic package on this machine, so I took the prebuilt tarball from GitHub. It’s also on Homebrew and crates.io (cargo install difftastic).
$ difft --version
Difftastic 0.72.0
Revision: 6201bc9 2026-10-29
Toolchain: 1.85.0
System: linux x86_64
The binary is 90,763,240 bytes, because it carries a parser for every language it knows (difft --list-languages names 62 of them). That’s a 90 MB diff tool. I’m not complaining. I’m just saying diff is about 140 KB and has never once told me a lie. Every capture below uses --color never so it pastes cleanly. In a terminal the changed tokens are highlighted, and that highlighting is where most of the information lives, so the plain-text captures below undersell the real thing.
What it gets right (the grudging part)
Here’s the pitch, and it delivers. I took a small JavaScript function and reformatted it: braces moved to new lines, indentation from 2 spaces to 4, a one-line loop body unrolled. The behaviour didn’t change at all.
$ cat before.js
function total(items) {
let sum = 0;
for (const i of items) { sum += i.price * i.qty; }
return sum;
}
$ cat after.js
function total(items)
{
let sum = 0;
for (const i of items) {
sum += i.price * i.qty;
}
return sum;
}
$ difft --color never before.js after.js
after.js --- JavaScript
No syntactic changes.
$ diff before.js after.js | wc -l
13
Thirteen lines of noise from diff, one honest sentence from difftastic. Then I made a real change on top of the reformat (i.qty → i.quantity), and it aligned the two versions side by side so I could see the rename through the reformat:
$ difft --color never before.js renamed.js
renamed.js --- JavaScript
1 function total(items) { 1 function total(items)
. 2 {
2 let sum = 0; 3 let sum = 0;
3 for (const i of items) { sum += i.p 4 for (const i of items) {
. rice * i.qty; } .
. 5 sum += i.price * i.quantity;
. 6 }
4 return sum; 7 return sum;
5 } 8 }
Then I threw everything else I could think of at it. All of these passed, and I’m reporting the boring passes too, because “it mostly works” isn’t a measurement:
| Scenario | What difftastic said | Correct? |
|---|---|---|
| JS reformat, no behaviour change | No syntactic changes. |
✅ |
Minified JSON vs python3 -m json.tool output |
No syntactic changes. |
✅ |
"a b" → "a b" inside a Python string |
shown as a change | ✅ |
Comment-only edit (retry 3 times → retry 5 times) |
shown as a change | ✅ |
| Python file with a syntax error | Text (2 Python parse errors, exceeded DFT_PARSE_ERROR_LIMIT, first at 1:0), then a line diff |
✅ |
Unknown extension (.conf) with extra spaces |
Text, shown as a change |
✅ |
| One byte flipped in a 2 KiB binary | Binary file modified (old: 2.0 KiB, new: 2.0 KiB). |
✅ |
YAML key dedented from prod: to top level |
shown as a change | ✅ |
YAML if: false moved out of a GitHub Actions job |
shown as a change | ✅ |
Two of those deserve credit by name. The parse-error fallback is honest: when a file doesn’t parse, difftastic doesn’t make up a tree. It says so in the header and falls back to a line diff, so you never get a confident structural answer about code it couldn’t read. The YAML results matter because indentation changes meaning in YAML just as it does in Python, and difftastic got both YAML cases right. Keep that in mind for the next section.
Surprise one: a Python line changes blocks and it says nothing
Here’s a cleanup function. It loops over files and removes the expired ones. Then someone (a merge conflict, a bad paste, an editor that “helpfully” re-indented) moves remove(f) one level to the left:
$ diff -u purge_before.py purge_after.py | tail -5
for f in files:
if f.expired:
log(f)
- remove(f)
+ remove(f)
$ difft --color never --exit-code purge_before.py purge_after.py; echo "exit=$?"
purge_after.py --- Python
No syntactic changes.
exit=0
I didn’t take its word that this is harmless. I wrote a six-line stub, runpurge.py, that runs each version’s purge() against three fake files, where only old.log is expired:
$ python3 -I /tmp/dtscripts/runpurge.py purge_before.py
purge_before.py removed: ['old.log']
$ python3 -I /tmp/dtscripts/runpurge.py purge_after.py
purge_after.py removed: ['old.log', 'prod.db', 'keys.pem']
That’s the whole bug. Four spaces turned “delete expired logs” into “delete everything”, and the structural diff, the tool you chose so you’d see real changes and skip the noise, filed it as noise. With --exit-code it still exits 0. Now ask it a slightly different question about the same two files:
$ difft --color never --check-only --exit-code purge_before.py purge_after.py; echo "exit=$?"
purge_after.py --- Python
Has syntactic changes.
exit=1
So --check-only knows. The full diff doesn’t. Same tool, same files, two answers. That fits the maintainer’s own diagnosis in issue #587, open since 2023-10-25. He describes it as a display issue: the diffing logic finds the change, but the display code assumes a structural change always comes with some new tokens to highlight. When a line changes blocks in Python, no token is new. Only the indentation moved, and indentation isn’t a token. Two later reports with the same shape of bug (#669 in 2024, #818 in 2025) were closed as duplicates of it. No new upstream issue from me: it’s already filed, triaged and explained, and a fourth copy wouldn’t help.
One example is an anecdote, so I generated a thousand cases. My script built random Python snippets: one if, for, while, with or try block, some statements before and after it, each one randomly either inside a function or at module level. Then it moved one statement across the block boundary, in or out. For every pair, Python’s own ast module confirmed the two programs really are different. Then I ran difft --exit-code, difft --check-only --exit-code and plain diff -q on each pair:
| Seed 2038, 1,000 pairs | Caught the change |
|---|---|
diff -q |
1,000 / 1,000 ✅ |
difft --check-only --exit-code |
1,000 / 1,000 ✅ |
difft --exit-code (the actual diff) |
810 / 1,000 ❌ — 190 printed No syntactic changes. |
A second run with seed 1999 missed 202 of 1,000. Breaking the first run down by where the moved line lived shows the pattern:
| Block | Inside a function: missed | At module level: missed |
|---|---|---|
if |
31 / 103 | 0 / 99 |
for |
3 / 101 | 0 / 100 |
while |
68 / 86 | 0 / 107 |
with |
88 / 101 | 0 / 111 |
try/finally |
0 / 101 | 0 / 91 |
At module level it caught 508 out of 508. Inside a function, where most real Python lives, it missed between 0% and 87% depending on the block type. That’s why my first quick test (a statement moved under a top-level for) passed, and why you might try it once, see it work, and trust it. My first draft of the harness also reported that --check-only caught nothing, because I’d forgotten to pass it --exit-code. That was my bug, not difftastic’s. I fixed it and reran before writing that row.
The failure this prevents: reviewing a Python PR with difftastic as your only diff, scrolling past a file marked No syntactic changes., and approving a behaviour change nobody showed you. It follows the change into history, too: git log -p --ext-diff with difft as the external diff printed the same No syntactic changes. for the commit that made the move. If your review depends on difftastic, run plain git diff on any Python file it calls clean. If you must script it, --check-only --exit-code is the call that told the truth in all 1,000 cases.
Surprise two: CRLF is “No changes.” Even when asked directly.
A classic: someone on Windows saves deploy.sh and every line now ends in \r\n. Bash reads set -e\r and chokes on it:
$ bash deploy-win.sh
deploy-win.sh: line 2: set: -: invalid option
set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
deployed
Read that last line again: the script kept going. set -e was never applied, so from here on any failing command gets ignored. That’s a real behaviour change, caused entirely by line endings. diff -q says the files differ. difftastic says:
$ difft --color never --check-only --exit-code deploy.sh deploy-win.sh; echo "exit=$?"
deploy-win.sh --- Bash
No changes.
exit=0
Not even “no syntactic changes”: just “No changes”, with --check-only, the mode that was honest in the Python case. It does the same for a plain .txt file. Ignoring line endings is a reasonable default for reading a diff, and most of the time CRLF churn really is noise. But “No changes.” is a factual claim, and here it’s false. The failure this prevents: a CRLF conversion that breaks a shell script on Linux sails through a review done with difftastic. Keep .gitattributes (*.sh text eol=lf) as the real fix, and let git diff be the one that complains.
Surprise three: --exit-code is opt-in, and git can’t handle it
By default, difft exits 0 whether or not the files differ:
$ difft --color never renamed.js before.js >/dev/null; echo "exit=$?"
exit=0
$ difft --color never --exit-code before.js renamed.js >/dev/null; echo "exit=$?"
exit=1
That’s documented, and it’s also the reason a CI script like difft old new && echo same says “same” every single time. So you add --exit-code and wire it into git the usual way, as the external diff. Git sees the exit 1 and stops:
$ GIT_EXTERNAL_DIFF="difft --exit-code" DFT_COLOR=never git diff >/dev/null; echo "git exit=$?"
fatal: external diff died, stopping at app.js
git exit=128
Git expects an external diff to exit 0, and treats anything else as a crash. Without the flag, the same setup works fine in my test repo, including on one I named we<newline>ird 🦆; DROP TABLE.py. It diffed that one correctly too. The newline in the name went straight to the terminal, which split the file header across two lines, but nothing broke. The rule: --exit-code belongs in scripts that call difft directly, never in GIT_EXTERNAL_DIFF or diff.external.
Surprise four: past 1 MB, the same answer changes
difftastic protects itself from huge inputs. Above DFT_BYTE_LIMIT (1,000,000 bytes by default) it falls back to a line diff, and the header says so. I generated JavaScript files of one-line functions and timed one changed token in each:
| File | Mode | Time | Peak memory |
|---|---|---|---|
| 9,000 lines, 412 KB | structural | 0.67 s | 197 MB |
| 20,000 lines, 938 KB | structural | 1.62 s | 401 MB |
| 30,000 lines, 1.4 MB | Text (1.4 MiB exceeded DFT_BYTE_LIMIT) |
0.05 s | 50 MB |
30,000 lines, DFT_BYTE_LIMIT=5000000 |
structural | 2.66 s | 585 MB |
The fallback is the right call, and the header tells you it happened. The catch: I made a reformat-only change (wrapping one function across three lines) in the 30,000-line file. Under the default limit, --exit-code returned 1 and showed a text diff. With the limit raised, the same pair returned 0: No syntactic changes. So if you script difftastic to mean “only real changes”, the answer depends on file size as well as content, and the threshold is a single megabyte, which generated code passes easily. And note the memory: about 20 KB per line structurally. A 30,000-line file needed more than half a gigabyte to tell me nothing had changed.
The setup I’d actually use
For reading diffs, in your git config. No exit-code flag here:
```bash lh:norun git config –global diff.external difft
or one-off, leaving your normal git diff alone:
GIT_EXTERNAL_DIFF=difft git log -p –ext-diff ```
And a short list of rules, each with the failure it prevents:
- Gate with
git diff --exit-code, neverdifft. This prevents the 190-in-1,000 Python miss, the CRLF “No changes.” and the size-dependent answers. - Distrust
No syntactic changes.on Python files. Glance atgit diff -- file.pybefore approving. This prevents shippingpurge()withprod.dbon its kill list. - If you need a yes/no from difftastic, use
--check-only --exit-code. It was right on 1,000 of 1,000 Python moves. It was still wrong on CRLF. - Keep
--exit-codeout ofGIT_EXTERNAL_DIFF. This preventsfatal: external diff died.
Verdict
Use it to read diffs, never to gate them. It’s the best diff reader I’ve tested for code that got reformatted. It’s honest when it falls back to text (it puts the reason in the header), and it got every non-Python scenario I threw at it right, YAML indentation included. But its headline sentence, No syntactic changes., was wrong in 190 of 1,000 Python block moves and wrong about a CRLF change that broke a shell script. It survives a normal Tuesday, which is reading a refactor. It doesn’t survive the bad Tuesday, which is approving a Python PR with it. And on the Tuesday where the intern has sudo, the intern has wired difft --exit-code into the deploy check, and the deploy check says “same”.