# difftastic

> Structural diff tool that compares files based on their syntax rather than lines

Stars: 26.1k · Language: Rust · License: MIT · Categories: Dev Tools

- Repository: https://github.com/Wilfred/difftastic
- Website: https://difftastic.wilfred.me.uk/
- Page: https://www.trmn.sh/tools/difftastic

## Overview

Difftastic is a structural diff tool that analyzes and compares files based on their parsed syntax trees rather than line-by-line differences. It parses source code into abstract syntax trees (ASTs) and uses Dijkstra's algorithm to identify the actual syntactic changes between files. This approach allows it to understand when changes are purely cosmetic (like whitespace or formatting) versus substantive code modifications.

The tool supports over 30 programming languages and integrates with version control systems including Git and Mercurial. When difftastic encounters files it cannot parse or unsupported file types, it falls back to a line-oriented diff with word highlighting. It can handle merge conflicts by parsing conflict markers and diffing the conflicting sections, and offers a `--check-only` mode for quickly determining if files have syntactic differences without generating a full diff.

Difftastic displays results in a side-by-side format and can be configured through environment variables like `DFT_PARSE_ERROR_LIMIT` and `DFT_BACKGROUND`. However, it has known performance limitations with large files containing many changes and high memory usage. The tool is designed for human consumption rather than generating patches, making it complementary to traditional diff tools rather than a replacement for patch-based workflows.

![Difftastic comparing Rust code](https://media.trmn.sh/cached/6b825338d8b63bfb61b110ca3a9f43f0acefcf19fbd56d00f4f986f9000f2441.png)

![Difftastic comparing HTML](https://media.trmn.sh/cached/c1be4779856130dd7160f7f8895375df427f2d1daaed9fb02fc9ac8be622da82.png)

![Difftastic comparing JavaScript](https://media.trmn.sh/cached/fd7e8e9fd89e5510c83fc5cb3f29a21cfc515b4942143ddfb46dcb0c8f513e97.png)

## Alternatives

- [fnm](https://www.trmn.sh/tools/fnm.md): Fast Node.js version manager built in Rust with support for .node-version and .nvmrc files (Rust, 27.3k stars)
- [hyperfine](https://www.trmn.sh/tools/hyperfine.md): Command-line benchmarking tool that runs statistical analysis across multiple timing runs of shell commands (Rust, 29.2k stars)
- [Hurl](https://www.trmn.sh/tools/hurl.md): Command line tool that runs and tests HTTP requests defined in plain text files, with request chaining, captures, asserts, and CI reports. (Rust, 19.3k stars)
- [asciinema](https://www.trmn.sh/tools/asciinema.md): Command-line tool for recording and live streaming terminal sessions to lightweight asciicast files (Rust, 17.9k stars)
- [mise](https://www.trmn.sh/tools/mise.md): CLI tool for managing development environments with version-controlled tools, environment variables, and tasks (Rust, 35.7k stars)

## Guides

- [A terminal git workflow with lazygit and delta](https://www.trmn.sh/guides/lazygit-delta-workflow): Install lazygit and delta, set delta as git's pager, render lazygit diffs with it, and stage hunks, commit and rebase from the keyboard.

---

Canonical: https://www.trmn.sh/tools/difftastic
