# Hunk vs difftastic

> Hunk vs difftastic. difftastic changes what the diff says by parsing your code with tree-sitter. Hunk changes how you read a changeset. What each is for, and why they do not compose.

Source: https://hunk.dev/compare/hunk-vs-difftastic/ · Last checked: 2026-09-01

difftastic changes what the diff says. It parses both versions with tree-sitter and reports syntactic changes, so a reindent or a wrapped block stops reading as a rewrite. Hunk changes how you read a changeset: one multi-file stream, a file sidebar, split layouts, expandable context, agent notes. Hunk is line-based and does no AST diffing. difftastic has no review UI. They do not pipe into each other, so most people run difftastic as an external diff and review in Hunk.

## Choose Hunk if

- You review changesets that span many files and want navigation, not a longer scroll.
- You want a diff you can drive with the mouse and reconfigure while reading it.
- An agent wrote the change and you want its notes anchored to hunks.
- You need patch input. `hunk patch -` reviews any unified diff from stdin.

## Choose difftastic if

- The change is a refactor and the line diff is lying about what moved.
- You want reformatting and wrapped blocks reported structurally.
- You work in one file at a time and a pager is enough.
- Your languages are among difftastic's tree-sitter parsers.

## What difftastic is

difftastic parses both versions of a file with tree-sitter and diffs the trees instead of the lines. The payoff shows up where line diffs are worst. Wrap a block in an `if`, reindent a function, move a closing brace, and difftastic reports the actual change instead of a wall of red and green.

Its manual lists more than fifty programming languages plus ten structured text formats, and `difft --list-languages` prints what your build supports. It falls back to line-oriented diffing with word highlighting when it cannot parse a file, and it is written in Rust and usually wired in as Git's external diff.

Its docs are clear about the limits. Producing applicable patches, merging, and ignoring reordered elements are stated non-goals, and the README lists under Known Issues that difftastic scales relatively poorly on files with a large number of changes and can use a lot of memory.

The usual difftastic wiring:

```bash
# one command
GIT_EXTERNAL_DIFF=difft git diff

# or make it the default external diff
git config --global diff.external difft
# other subcommands then need --ext-diff:
git show --ext-diff
```

## What Hunk is

Hunk is line-based and is not competing on diff algorithms. It changes the reading. Every visible file is one continuous review stream, the sidebar indexes that stream, `[` and `]` walk hunks across the whole changeset, and `z` expands unchanged context around the hunk you are on without re-running anything.

It is a real terminal UI, not printed output, so layout, wrapping, line numbers, and theme all change while you read, the mouse works, and `hunk diff --watch` keeps the review current. If an agent produced the change, it can attach reasoning to specific hunks through `hunk session`, and those notes render inline beside the code.

## They do not compose, and that is fine

You cannot pipe difftastic into Hunk. difftastic emits its own rendered output, or JSON with `--display json`, but never a unified diff, and Hunk's review stream is built from unified diffs. Setting `GIT_EXTERNAL_DIFF=difft` and then opening `hunk diff` does not stack the two. Hunk reads Git's own patch output.

Not much is lost, because you reach for them at different moments. When one file's diff looks nonsensical after a reformat, run difftastic on that file. When you are reviewing a change across a dozen files, open Hunk.

Both, at the moments each is good:

```bash
curl -fsSL https://hunk.dev/install.sh | sh

# structure, for one confusing file
GIT_EXTERNAL_DIFF=difft git diff -- src/parser.ts

# review, for the whole changeset
hunk diff
```

## Hunk vs difftastic, capability by capability

difftastic is written in Rust and licensed MIT. Hunk is TypeScript, MIT, and ships as a standalone binary for macOS, Linux, and Windows.

| Capability | Hunk | difftastic |
| --- | --- | --- |
| Structural / AST-aware diffing — difftastic's whole reason to exist. Hunk is line-based with word-level highlighting inside changed lines. | No | Yes |
| Line-oriented unified diff — difftastic falls back to line-oriented diffing with word highlighting for files it cannot parse. | Yes | Partly |
| Interactive review UI — difftastic prints to the terminal, so scrolling is your pager's job. | Yes | No |
| Multi-file review stream with a sidebar | Yes | No |
| Split and stack layouts switchable mid-review | Yes | No |
| Themes — Hunk ships 65 bundled themes and takes custom ones. difftastic has a light or dark background setting rather than a theme catalog. | Yes | Partly |
| Mouse-driven navigation | Yes | No |
| Expand unchanged context in place | Yes | No |
| Watch mode that reloads the review | Yes | No |
| Inline agent and human annotations on a hunk | Yes | No |
| Reads a unified diff or patch from stdin — `hunk patch -` reviews any patch. difftastic reads the two files, not a patch. | Yes | No |
| Output usable as a patch — Producing applicable patches is a stated difftastic non-goal, and Hunk is a viewer. | No | No |
| Insensitive to reordered elements — difftastic lists this as a non-goal. Reordering still shows as a change in both tools. | No | No |
| Git integration — difftastic goes in `GIT_EXTERNAL_DIFF` or `diff.external`. Hunk runs natively, as a pager, or as a difftool. | Yes | Yes |
| Native Jujutsu and Sapling support — difftastic works wherever a VCS accepts an external diff command. Hunk detects jj and Sapling workspaces and takes native revsets. | Yes | Partly |
| TypeScript extension API | Yes | No |

## Questions people ask

### Can I use difftastic as Hunk's diff engine?

No. Hunk builds its review stream from unified diffs, and difftastic's output is its own rendered display, or JSON, rather than a patch. Configure difftastic as a Git external diff for the files where structure matters, and use `hunk diff` to review the changeset.

### Does Hunk do structural or AST diffing?

No. Hunk highlights changes at word level within a line and honors Git's `--color-moved` for moved blocks, but it does not parse code into a syntax tree. If you need AST-level diffing, difftastic is the right tool.

### Which one handles a big refactor better?

Depends on the shape of it. For one file that was reformatted or rewrapped, difftastic tells you the truth faster. For a refactor spread across many files, Hunk's review stream plus `--color-moved` is the more workable read, because the problem is tracking thirty files rather than understanding one.

### Is difftastic slower than Hunk?

Hard to compare directly, since one is a diff algorithm and the other is a UI. What is documented is that difftastic's tree diffing gets expensive on files with many changes. Hunk's cost scales with rendering the changeset instead, and the experimental `hunk --fast` offloads eligible syntax highlighting.

## Sources

- [difftastic, GitHub repository](https://github.com/Wilfred/difftastic)
- [Difftastic manual](https://difftastic.wilfred.me.uk/)
- [Hunk: files and patches](https://hunk.dev/docs/workflows/files-and-patches/)
- [Hunk: quick start](https://hunk.dev/docs/start/quick-start/)

## Other comparisons

- [Hunk vs delta](https://hunk.dev/compare/hunk-vs-delta/) — delta restyles the text Git already printed. Hunk turns the same changeset into a review UI. Most people keep both.
- [Hunk vs diff-so-fancy](https://hunk.dev/compare/hunk-vs-diff-so-fancy/) — diff-so-fancy tidies Git's diff output. Hunk replaces the reading experience. The gap is bigger than it looks.
- [Hunk vs git diff](https://hunk.dev/compare/hunk-vs-git-diff/) — git diff prints the patch. Hunk renders the same patch as something you can navigate. Git stays the source of truth.
- [Hunk vs Plannotator](https://hunk.dev/compare/hunk-vs-plannotator/) — Both exist because agents write more code than you can read. Plannotator reviews it in the browser and covers plans. Hunk stays in the terminal.
