JSON 转 CSV
将结构化 JSON 对象或数组转换为扁平化的 CSV 表格文本。接收合法 JSON 数组或对象列表,输出带表头的逗号分隔数据,支持自定义分隔符与引号包裹策略。本工具处理二维及浅层嵌套数据,极深层级对象将序列化为内联字符串展示。
将结构化 JSON 数据转换为规范 CSV 表格
适用于把接口返回的 JSON 对象数组或行式记录整理为电子表格可识别的 CSV 文件。工具支持对象嵌套点号扁平化、数组索引展开、自定义分隔符与表头行控制,并按 RFC 4180 规则处理含逗号、引号与换行的单元格。数据转换仅在本地执行。
操作步骤
- 在输入框中粘贴标准 JSON 数组、单个对象或 NDJSON(JSON Lines)文本。
- 配置转换参数:根据目标表格软件设置分隔符(默认为逗号 ,),确认是否保留表头行,并在自动引号或始终引号之间选择。
- 在右侧查看输出结果,确认含特殊字符字段已被双引号正确包裹,点击复制或导出为 .csv 文件。
转换含逗号、空格和数字的对象数组
输入
[
{ "name": "Alice", "age": 28, "city": "London, UK" },
{ "name": "Bob", "age": 34, "city": "Paris" }
]选项
分隔符为逗号 (,);包含表头行;自动引号 (auto)
输出 / 解析结果
name,age,city Alice,28,"London, UK" Bob,34,Paris
限制与常见问题
- 输入必须是对象或对象数组;传入单纯的基础数据类型(如数字、字符串字面量)会报错并提示输入格式无效。
- 在自动引号模式下,仅当单元格包含分隔符、双引号或换行符时才加双引号,内部双引号会自动转义为 "";若需与某些严格解析器兼容,可切换为“始终使用引号”。
- 嵌套对象按点号(user.address.city)展开,数组按索引(items[0])展开;缺失字段对应单元格输出为空,行间采用 \r\n 连接。
- 导入表格前核对不可信单元格:引号转义不会阻止表格软件把以 =、+、- 或 @ 开头的内容解释为公式。请按文本导入并检查结果。
相关任务与参考链接
Convert structured JSON data into RFC-compliant CSV
Use this tool to transform JSON object arrays or line-delimited records into standard CSV files suitable for spreadsheets and data pipelines. It supports dot-notation flattening for nested objects, array indexing, customizable delimiters, and header toggling while adhering to RFC 4180 quoting for commas, quotes, and newlines. Processing occurs entirely in your browser.
Steps
- Paste standard JSON (array of objects or single object) or NDJSON (JSON Lines) into the code input editor.
- Adjust options: set the delimiter (default comma ,), toggle the column header row, and select automatic or forced quoting.
- Inspect the resulting CSV in the output pane, verify that special characters are quoted, and copy or download the .csv file.
Convert an object array containing commas, spaces, and numbers
Input
[
{ "name": "Alice", "age": 28, "city": "London, UK" },
{ "name": "Bob", "age": 34, "city": "Paris" }
]Options
Delimiter comma (,); include headers; auto quoting
Output / inspection
name,age,city Alice,28,"London, UK" Bob,34,Paris
Limits and common issues
- Input must be an object or array of objects; bare primitives (such as standalone numbers or strings) will throw an error.
- Auto-quoting encloses cells in double quotes only when they contain the delimiter, double quotes, or newlines, escaping embedded quotes as ""; choose 'Always quote' if your downstream tool requires uniform quoting.
- Nested structures are flattened using dot notation (e.g. user.address.city) and bracket indices (items[0]); missing keys produce empty cells, and rows are delimited with \r\n.
- Check untrusted cells before spreadsheet import: CSV quoting does not prevent spreadsheet software from interpreting values starting with =, +, - or @ as formulas. Import as text and inspect the result.