difftastic: Compare Code by Its Syntax

difftastic: Compare Code by Its Syntax

Summary

Difftastic is a structural diff tool that compares source files according to their syntax instead of only comparing lines. It helps developers review code changes across formatting shifts, with line-based fallback when parsing fails.

At a glance

Language
Rust
License
MIT
Stars
26k
Forks
523
Added to OSRepos
January 28, 2026
Last analyzed
October 3, 2026
View on GitHub

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Overview

Difftastic compares files by parsing their syntax, so it can show which code structures changed even when formatting or line breaks differ. This makes it useful when ordinary line-oriented diffs produce noisy results during code review.

It is a command-line tool for developers who want syntax-aware comparisons in their terminal or version-control workflows. It supports more than 30 programming languages and falls back to a line-oriented diff for unrecognized file types or, by default, when parsing encounters errors.

Key Features

  • Highlights structural changes in supported programming languages.
  • Handles code that has been reformatted or split across different lines.
  • Distinguishes syntactically meaningful whitespace from indentation changes.
  • Supports more than 30 languages, with a line-oriented fallback for unrecognized extensions.
  • Integrates with Git and Mercurial workflows.
  • Can compare files for syntactic changes only with --check-only.
  • Can parse files containing merge-conflict markers to compare the conflicting versions.

Use Cases

  • Developers reviewing refactors where code has moved or been reformatted across lines.
  • Teams using Git or Mercurial that want syntax-aware diffs in their existing workflows.
  • Maintainers checking whether two files differ structurally without generating a full diff.
  • Developers investigating changes in files with minor parse errors, when allowing a limited number of errors is appropriate.

Project Facts

  • Language: Rust
  • License: MIT
  • Stars: 26k
  • Forks: 523
  • Topics: diff, tree-sitter
  • Archived: No

Getting Started

See the installation instructions in the manual for setup. After installation, compare two files with difft file1 file2. The Git integration guide explains how to use it in Git workflows.

Considerations

  • Difftastic can use substantial memory and scale poorly on files with many changes.
  • Its side-by-side display may be confusing in some cases.
  • Parser errors can trigger a line-oriented fallback, so results may not be syntax-aware for every file.
  • It produces output for people to read, not patch files for applying changes, and it does not perform AST merges.
  • The repository notes that releases regularly fix crashes, so robustness is an ongoing consideration.

Source repository

Open the original repository on GitHub.

18 counted GitHub visits

View on GitHub

Related repositories

Similar repositories that may be relevant next.

OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️