Skip to content
cosmodev ~/tools/csv-diff

CSV 差异对比

Data & DevOps

按键列比较两个 CSV:新增、删除和变更的行,并指出存在差异的列名。正确处理含逗号、引号和换行的引号单元格。完全在浏览器中本地运行,并可通过链接分享。

行变更列表
可复制的行列表将显示在这里。

(文档为英文)

What it does

Compares two CSVs by key, like a database diff. Rows are matched on a key column (the first column by default, or any column you name); the tool reports rows added, removed and changed — a changed row names exactly which columns differ. Row order does not matter. Quoted cells are parsed per RFC 4180, so commas, escaped quotes and embedded newlines inside cells are handled correctly. Headers must match exactly; duplicate keys and ragged rows are rejected with the row number named. Everything runs locally in your browser.

How to use it

  1. Paste the original into Left CSV and the changed version into Right CSV, or tap Sample.
  2. Type a header name into Key column to match rows on something other than the first column. Leave it empty for the default.
  3. The row diff (right) shows green + added rows, red − removed rows, and accent ~ changed rows with the differing columns listed.
  4. Copy list takes a plain-text version of the diff for commit messages or review.
  5. Copy share link encodes both documents and the key column in the URL.

Examples

Given the sample, sku 1 changed price, sku 2 was removed, sku 4 was added:

~ 1 (qty) · − 2 · + 4

Row order never matters — two files with the same rows in different order diff as identical.

A quoted cell with a comma stays one cell:

1,"widget, large" and 1,"widget, large" — identical.

How keyed row diffing works

The tool builds a map of key → row on each side, then unions the keys:

Case Report
Key only on the right added row, full record shown
Key only on the left removed row, full record shown
Key on both, cells differ changed row, differing column names sorted
Headers differ error, both headers printed
Duplicate key on one side error, side and key named
Row with wrong cell count error, row number and counts named

Unlike positional JSON diffing, this is alignment by identity — rows can be reordered, sorted or filtered without producing noise. For document-shaped data without a key, use JSON Diff.

源代码13 种语言

100% 客户端运行 · 你的数据永远不会离开浏览器。 觉得好用?分享给同事吧。