LinuxCommandLibrary

difft

Compare differences between text files side-by-side

TLDR

Compare two files or directories

$ difft [path/to/file_or_directory1] [path/to/file_or_directory2]
copy

Only report the presence of differences between the files
$ difft --check-only [path/to/file1] [path/to/file2]
copy

Specify the display mode (default is side-by-side)
$ difft --display [side-by-side|side-by-side-show-both|inline|json] [path/to/file1] [path/to/file2]
copy

Ignore comments when comparing
$ difft --ignore-comments [path/to/file1] [path/to/file2]
copy

Enable/Disable syntax highlighting of source code (default is on)
$ difft --syntax-highlight [on|off] [path/to/file1] [path/to/file2]
copy

Do not output anything at all if there are no differences between files
$ difft --skip-unchanged [path/to/file_or_directory1] [path/to/file_or_directory2]
copy

Print all programming languages supported by the tool, along with their extensions
$ difft --list-languages
copy

SYNOPSIS

difft [OPTIONS] <LEFT> <RIGHT>

PARAMETERS

-h, --help
    Print help information

-V, --version
    Print version information

--color <WHEN>
    Color mode: always, never, auto (default)

--context <LINES>
    Context lines around changes (default: 3)

--display <LANG>
    Display language: infer (default), context, or name

--dump-ast <PATH>
    Dump parsed AST as JSON to file

--edit-script
    Print LCS edit script instead of visual diff

--hunk-line-limit <LINES>
    Max lines before skipping hunk (default: 4)

--language-infer-paths <REGEX>
    Regexes for path-based language inference

--left-title <TITLE>
    Custom title for left pane

--line-numbers
    Show line numbers

--no-config
    Ignore difftastic config file

--palette <PALETTE>
    Color scheme: ansi (default), github, onedark, etc.

--right-title <TITLE>
    Custom title for right pane

--side-by-side
    Use side-by-side layout (default: inline)

--strip-trailing-cr
    Strip carriage returns (Windows)

--summary
    Print change summary

--tab-width <WIDTH>
    Tab width (default: 8)

--width <COLUMNS>
    Terminal width (default: 80)

--wrap <HOW>
    Line wrapping: no (default), simple

DESCRIPTION

Difftastic (difft) is a modern diff tool designed for source code, providing fine-grained, syntax-highlighted diffs. Unlike traditional tools like diff(1) or git diff, which treat code as plain text and show line-based changes, difft parses code using Tree-sitter grammars for dozens of languages. It displays changes within lines—such as reordered parameters, renamed variables, or refactored functions—while graying out unchanged code for clarity.

Key strengths include beautiful side-by-side views, accurate move detection, and efficient handling of large files. Syntax highlighting makes diffs readable, with customizable palettes (e.g., GitHub style). It's written in Rust, blazing fast, and supports config files for defaults. Perfect for code reviews, pull requests, or any developer workflow needing precise change visualization.

Supports languages like Rust, C/C++, Python, Java, Go, JavaScript/TypeScript, Haskell, Ruby, Lua, JSON, Markdown, and more. Install via package managers (e.g., apt install difftastic on Ubuntu 23.10+) or Cargo.

CAVEATS

Not installed by default on most distros; requires manual installation. Some languages have partial support. Large files may need tuning for performance.

SUPPORTED LANGUAGES

Over 30: Rust, C/C++, Python, Java, Go, JS/TS, Haskell, Ruby, Lua, Zig, JSON, Markdown, HTML, CSS, etc.
Full list: difft --list-languages

INSTALLATION

Cargo: cargo install difftastic
Arch: pacman -S difftastic
Ubuntu/Debian (24.04+): apt install difftastic
Fedora: dnf install difftastic
macOS: brew install difftastic

CONFIG FILE

~/.config/difftastic/difft.toml for defaults like side_by_side = true, palette = "github"

HISTORY

Created by Wilfred Hughes in 2020 as a frustration with line-based diffs. Written in Rust using Tree-sitter. First release v0.1.0 in Oct 2020; now at v0.35+ with 100+ contributors on GitHub. Gained popularity via integrations like GitHub CLI and VS Code.

SEE ALSO

diff(1), git-diff(1), delta(1), diff-so-fancy(1)

Copied to clipboard