difftastic logo

difftastic

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

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

Difftastic comparing HTML

Difftastic comparing JavaScript

Alternatives & related tools

add a badge to your README

Maintain difftastic? Show that it's featured on trmn. The badge links back to this page.

Featured on trmn
Markdown
[![Featured on trmn](https://www.trmn.sh/badge/difftastic.svg)](https://www.trmn.sh/tools/difftastic?utm_source=badge)
HTML
<a href="https://www.trmn.sh/tools/difftastic?utm_source=badge"><img src="https://www.trmn.sh/badge/difftastic.svg" alt="Featured on trmn" height="20"></a>