Library for comparing tables and producing diffs, with CLI for CSV/TSV/SQLite and git integration
daff is a library and command-line tool for comparing tabular data and generating structured diffs. It identifies row and column changes between tables that share a common origin, producing output that can be used as patch files. The tool supports CSV, TSV, SQLite, and ndjson formats, with specialized handling for tables where row order may or may not be meaningful.
The CLI provides diff, patch, merge, and render operations with extensive formatting options. Users can control context display, specify primary keys for matching rows, ignore specific columns, and output results in various formats including HTML with visual highlighting. The daff git csv command integrates with git repositories to provide intelligent CSV diffs and merges based on table structure rather than line-by-line comparison.
As a library, daff is implemented in Haxe and translated to multiple languages including JavaScript, Python, Java, C#, C++, Ruby, and PHP. The library expects users to provide table interfaces rather than creating its own data structures, allowing integration with existing data processing workflows. The diff format follows the tabular-diff specification and can represent insertions, deletions, updates, and column changes in a standardized way that supports both visualization and programmatic processing.
# via npm
npm install daff -g
# via pip
pip install daff
# via gem
gem install daff
# via composer
composer require paulfitz/daff-php
