CSV ⇄ JSON

Format swap, rows or objects, your call.

Convert both ways between CSV and JSON. First row becomes field names for CSV→JSON; all keys are merged into the header for JSON→CSV. Quoted fields and commas are handled.

Everything runs locally in your browser

What is this?

CSV→JSON: the first row is the header, each remaining row becomes an object, output is an array. JSON→CSV: accepts an array of objects (a single object is wrapped), merges all keys into the header, and quotes fields containing commas or quotes.

FAQ

Chinese looks garbled after JSON→CSV?

CSV is plain text; garbling usually happens when opened directly in Excel. Use a UTF-8 aware editor, or in Excel choose Data → From Text/CSV and select UTF-8.

Is anything uploaded?

No. Everything runs in your browser; nothing is sent to a server.

示例与注意事项Example & notes

一个例子A worked example

Excel 导出的 CSV 里有带逗号和换行的字段:粘贴后按引号规则正确解析,转成 JSON 数组再喂给程序。A CSV exported from Excel with commas and newlines inside fields parses correctly by quote rules, then becomes a JSON array for your code.

注意事项Things to watch

相关问答More Q&A

首行一定会当字段名吗?Is the first row always treated as headers?

默认是,可以关闭;关闭后 JSON 会以数组形式输出,适合纯数据表。By default yes, and you can turn it off — JSON then becomes arrays of arrays, which suits raw data tables.

对象数组转 CSV 时字段不一致怎么办?What happens when objects have different keys?

会取所有字段的并集,缺失处留空,因此不会丢列。The union of all keys is used and missing values are left blank, so no column is lost.

Further reading

觉得好用?Found it useful?