Ever spent 20 minutes hunting a single changed cell in a spreadsheet?
Use the terminal instead — it’s faster and keeps your data local.
This post shows practical csv diff command line options you can run in seconds: built-in tools (diff, comm, awk) for quick line-by-line checks, git diff for word-level tweaks, and CSV-aware utilities (csvdiff, daff) when you need key-based comparisons or to ignore timestamps.
You’ll get when to use each tool, exact commands to run, and common gotchas like headers, delimiters, and quoting.
Quick Command-Line Methods to Compare Two CSV Files

When you need to spot differences between two CSV exports and don’t want to open a GUI or upload files anywhere, the terminal is fastest. A quick diff command shows what changed between yesterday’s data dump and today’s, and you get immediate output right in your shell.
Most Unix-like systems (Linux, macOS, WSL on Windows) ship with diff, comm, and awk pre-installed. These text utilities work for simple CSV comparisons when the row order is stable and the structure is clean. For anything beyond a quick check, or when you need to ignore certain columns, a CSV-aware tool is better. But built-in commands handle a surprising number of one-off tasks.
Choosing between basic text diff and a CSV-specific tool depends on whether your rows are sorted, whether the order matters, and whether you need to ignore timestamps or compare only certain columns. If your CSVs are already sorted by a key and you want to see line-by-line changes, diff is enough. Row order scrambled or you need smarter comparisons? Reach for something CSV-aware.
- diff file1.csv file2.csv shows every line that differs between the two files, one per line.
- comm -3 file1.csv file2.csv prints lines unique to each file, suppressing lines that appear in both (requires sorted input).
- awk lets you write short scripts to compare specific columns, for example
awk -F, 'NR==FNR{a[$1]=$0;next} !($1 in a)' base.csv delta.csvto find rows by a key column. - sorted comparison pipe each file through sort then compare:
diff <(sort file1.csv) <(sort file2.csv)to ignore row order.
Using diff for CSV Comparison

The diff command compares files line by line and reports every difference it finds. When both CSVs have rows in the same order, diff immediately highlights additions, deletions, and modifications. The catch? A single reordered row causes diff to report it as a deletion and an addition, which clutters the output and hides the real changes.
For CSVs where row order isn’t guaranteed (database dumps, log exports, shuffled data), sort each file first and then diff the sorted results. Common diff flags include -y for side-by-side comparison and --suppress-common-lines to hide matching rows and show only the differences. Adding -u produces a unified diff format that’s easier to read when tracking down what changed in a specific field.
- Prepare the files. Confirm both CSVs use the same delimiter and have identical header rows (same column names, same order).
- Optional: sort. Run
sort file1.csv > file1_sorted.csvandsort file2.csv > file2_sorted.csvto keep row order from interfering. - Run diff. Execute
diff file1_sorted.csv file2_sorted.csvor use process substitutiondiff <(sort file1.csv) <(sort file2.csv)to skip intermediate files. - Interpret output. Lines prefixed with
<appear only in the first file, lines with>only in the second. A line range like42c42means line 42 changed.
Comparing CSV Files with git diff

Git’s diff engine can compare any two files, not just version-controlled source code. Running git diff --no-index file1.csv file2.csv treats both files as plain text and shows a unified diff, which is useful when you want Git’s whitespace and word-level comparison options even if the CSVs aren’t in a repository.
Use git diff --no-index --word-diff file1.csv file2.csv to see changes within individual cells rather than entire rows. This highlights modified values inside brackets and keeps the context readable. The --color-words flag shows inline changes with color highlighting, making it easier to spot a single edited field in a long row.
| Command | What It Does |
|---|---|
| git diff –no-index file1.csv file2.csv | Unified diff output for two CSV files not tracked in Git |
| git diff –no-index –word-diff file1.csv file2.csv | Shows changes at the word (cell) level with inline markers |
| git diff –no-index –color-words file1.csv file2.csv | Highlights modified portions in color for easier visual scanning |
CSV‑Aware Tools: csvdiff and daff

When plain diff isn’t enough and you need to compare CSVs by a unique key, ignore columns, or produce structured output for automation, dedicated CSV comparison tools handle the job. These utilities understand CSV structure and can identify added, modified, and deleted rows even when the order changes.
csvdiff
csvdiff is a command-line tool built specifically for comparing database table dumps saved as CSV. You specify which column (or columns) acts as the primary key, and csvdiff hashes each row to detect additions, modifications, and deletions. Installation is typically done via pip: pip install csvdiff. A basic command looks like csvdiff base.csv delta.csv --primary-key id where id is the column that uniquely identifies each row.
The tool supports multiple output formats including standard diff, word-diff, color-words, JSON, and rowmark (which labels each row as ADDED or MODIFIED). JSON output is useful when you need to feed the diff into another script or generate SQL statements. You can ignore specific columns (for example, --ignore created_at,updated_at) to skip timestamp fields that always differ.
daff
daff is another CSV diff tool that produces spreadsheet-style output and can generate patch files. Install it via npm (npm install -g daff-cli), pip, or package managers. Running daff base.csv delta.csv shows a table with markers: +++ for additions, --- for deletions, and -> for modifications, all aligned in the same column structure as your CSVs.
daff also supports generating a patch file that describes the changes in a machine-readable format, which you can apply to another CSV later. This is handy for version control workflows where you want to track data changes over time or merge edits from multiple sources.
Installing CLI CSV Diff Tools

Installing csvdiff and daff is straightforward on all major platforms. csvdiff is a Python package, so use pip. daff is distributed as a Node package and also available via pip. Both tools run cross-platform once their runtimes (Python or Node.js) are installed, and they work the same way on Linux, macOS, and Windows.
- Linux install Python and run
pip install csvdiff, or install Node and runnpm install -g daff-cli. Most distributions also offer csvdiff or daff in their package repositories. - macOS use Homebrew for quick setup:
brew install csvdifforbrew install daff, or fall back to pip/npm if Homebrew packages aren’t available. - Windows install Python from python.org or the Microsoft Store, then run
pip install csvdiffin Command Prompt or PowerShell. For daff, install Node.js and runnpm install -g daff-cli, or use WSL (Windows Subsystem for Linux) to access the same Linux install steps.
Handling Headers, Delimiters, and Quoting

CSV files can fail to match even when the data is identical if the headers are in a different order or the delimiter is a semicolon instead of a comma. Before running any comparison, confirm both files use the same delimiter and that column sequences align. If headers don’t match, most diff tools will report every row as changed, which is misleading.
Many CSV tools let you specify the delimiter explicitly. For awk, set the field separator with -F, or -F';' for semicolons. csvdiff and daff automatically detect delimiters in most cases, but you can override with flags like --separator ';' if needed. Quoted fields (cells wrapped in double quotes) are another common source of false positives. Tools that parse CSV structure correctly ignore differences in quoting style, but plain text diff will flag "value" as different from value, even though they represent the same data.
Output Formats and Reporting Options

Most CLI diff tools let you choose how to view the results. Colorized output makes additions green and deletions red, which speeds up visual inspection. Unified diff format shows context around each change, while side-by-side mode places both files next to each other for easier column-by-column comparison.
- Color output use
--coloror--color-wordsto highlight changes inline. Particularly useful for large files where scanning plain text is slow. - JSON csvdiff can output results as JSON (
--format json), which you can pipe into jq or a script to generate SQL insert/update statements or feed into an ETL pipeline. - Table or rowmark daff produces a table-style diff that looks like a spreadsheet, and csvdiff’s rowmark format labels each row with ADDED or MODIFIED, making it easy to filter or count changes with grep.
Cross‑Platform Usage (Linux, macOS, Windows)

diff, comm, and awk are native on Linux and macOS, so CSV comparison using built-in tools works out of the box. On Windows, install Git for Windows to get Git Bash, which includes diff and other Unix utilities, or enable WSL (Windows Subsystem for Linux) for a full Linux environment. Either option gives you the same command-line tools available on macOS and Linux.
Python-based csvdiff and Node-based daff run identically on all three platforms once the runtime is installed. This makes them a safer choice for teams working across different operating systems, because the syntax and output stay consistent regardless of whether you’re on a Mac, a Linux server, or a Windows laptop.
| Platform | Recommended Tools |
|---|---|
| Linux | diff, comm, awk (built-in); csvdiff/daff via pip/npm |
| macOS | diff, comm, awk (built-in); csvdiff/daff via Homebrew or pip/npm |
| Windows | Git Bash or WSL for diff/comm/awk; csvdiff/daff via pip/npm |
Final Words
In the action, we jumped straight into copy-ready terminal commands to compare two CSVs, walked through diff and git diff tricks, and introduced csv-aware tools like csvdiff and daff. We also covered installing tools, normalizing headers and delimiters, and tuning output formats for clearer reports.
Use simple text-based commands for quick checks, and switch to csv-aware tools when you need row/column accuracy. These csv diff command line tips should save setup time and help you spot issues fast. Keep experimenting—you’ll get quicker with practice.
FAQ
Q: How do I quickly compare two CSV files from the terminal?
A: Quickly compare two CSV files from the terminal using simple tools like diff, comm, awk, or sort|diff; use csvdiff or daff when you need CSV-aware row/column semantics and clearer output.
Q: How does diff compare CSV files and which flags help?
A: Diff compares CSVs line-by-line, so diff shows differing rows; use -y for side-by-side and –suppress-common-lines to hide matches, and sort files first if row order varies.
Q: Can I use git diff to compare CSV files and show cell-level changes?
A: Git diff can compare CSV files and –word-diff highlights cell-level changes; run git diff –no-index for files outside a repo and watch for whitespace or delimiter effects on results.
Q: What are csvdiff and daff and when should I use them?
A: Csvdiff and daff are CSV-aware tools: csvdiff highlights added/removed/modified rows, while daff shows spreadsheet-style table diffs and can generate patches—use them when structure matters beyond plain text diffs.
Q: How do I install csvdiff and daff on Linux, macOS, and Windows?
A: Install csvdiff with pip (pip install csvdiff); install daff via npm (npm i -g daff) or pip where available; on Windows use WSL, Git Bash, or PowerShell to run the same package managers.
Q: How should I handle headers, delimiters, and quoting before diffing CSVs?
A: Normalize headers and column order, set the correct delimiter flag for your tool, and ensure consistent quoting; small normalization steps avoid spurious differences during comparison.
Q: What output formats and reporting options do CSV diff tools offer?
A: CSV diff tools offer side-by-side, unified, colored terminal output, JSON or table exports, and patch formats—pick human-friendly side-by-side for review or JSON/patch for automation.
Q: Are command-line CSV diff tools cross-platform and which tools work best per OS?
A: Most CSV diff tools are cross-platform: diff is native on macOS/Linux, use Git Bash or WSL on Windows, and csvdiff/daff run anywhere you have Python or Node installed.
Q: How can I compare specific columns or do column-wise comparisons in CSVs?
A: Compare specific columns with awk using -F to set the delimiter, for example awk -F, ‘$2!=$3{print NR, $0}’ file.csv; for two-file column compares use key-based awk or join then compare columns.
Q: When should I sort CSV files before running a diff?
A: You should sort CSV files before running a diff when row order isn’t guaranteed; sorting by key columns produces meaningful set-based differences and avoids order-related false positives.
