Library and CLI tool for comparing tables, producing diffs, and applying patches to CSV, TSV, JSON, and SQLite data
Daff is a table comparison library and CLI tool that generates diffs between structured data files. It compares tables that share a common origin, producing summaries of differences that can be used as patch files. The tool supports CSV, TSV, SSV, PSV, JSON, and SQLite formats, with specialized handling for row and column-based changes rather than line-based diffs.
The CLI provides commands for diffing (daff a.csv b.csv), patching (daff patch a.csv patch.csv), merging three-way diffs, and rendering output as HTML. It includes context control, primary key specification, column filtering, and various output formatting options. The daff git csv command integrates with Git to provide intelligent CSV diff and merge handling that understands tabular structure.
The library API is available across multiple languages (JavaScript, Python, Ruby, PHP, Java, C#, C++) through Haxe compilation. It provides programmatic table comparison with compareTables(), alignment computation, diff generation, and patch application. The diff format follows the tabular-diff specification, using symbols like @@, +, -, and -> to indicate header rows, insertions, deletions, and updates.
Daff targets developers working with version-controlled data files, data analysts comparing datasets, and teams needing structured data diff capabilities in CI/CD pipelines. The tool excels at tracking changes in tables where traditional line-based diffs are inadequate for understanding row and column modifications.
# via npm
npm install daff -g
# via pip
pip install daff
# via gem
gem install daff
# via composer
composer require paulfitz/daff-php
