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
- 默认按逗号分隔,可切换制表符、分号等其他分隔符。Comma is the default delimiter; tab and semicolon are available.
- 含逗号或换行的字段必须用双引号包裹(Excel 导出时通常会自动加)。Fields containing commas or newlines must be quoted — Excel usually does this for you.
- 从 Excel 另存为 CSV 时请选「CSV UTF-8」,否则中文可能变成乱码。When saving from Excel choose "CSV UTF-8", otherwise Chinese text may arrive garbled.
相关问答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.