gitmyhub

difftastic

Rust ★ 26k updated 1d ago

a structural diff that understands syntax 🟥🟩

A command-line diff tool that understands code structure, showing what actually changed logically instead of just which lines moved around.

Rusttree-sitterDijkstra algorithmsetup: easycomplexity 2/5

Difftastic is a command-line diff tool that understands the structure of code rather than just its lines. A traditional diff (the standard tool for comparing two versions of a file) highlights every line that changed, even if the only difference is a reformatted line break or a shift in indentation. This produces noisy output that makes it hard to see what actually changed logically. Difftastic solves this by parsing both files as code, building a tree that represents their syntax, and then comparing those trees so it can tell you what changed in meaning rather than just in position.

For example, if you wrap a function call across multiple lines, difftastic knows nothing changed functionally. If you rename a variable inside a block, it highlights just that name. It supports over 30 programming languages, integrates with Git (so you can use it as your git diff viewer), and falls back to a line-based diff for unrecognized file types. Under the hood it uses Dijkstra's algorithm (a graph-search technique) on a syntax tree built by the tree-sitter parsing library.

Difftastic is written in Rust and available on crates.io. You would use it whenever reviewing code changes and wanting a clearer picture of what actually differs, rather than which lines moved around. It is not a merging tool and does not produce patch files.

Where it fits