JSON to CSV Converter|JSON 转 CSV

JSON 转 CSV | JSON to CSV Converter

JSON 转 CSV JSON to CSV Converter

JSON 数组对象转换为 CSV,便于导入 Excel / Google Sheets 做分析与透视表。
Convert a JSON array of objects into CSV for Excel / Sheets analysis (pivot tables, filtering, etc.).

1. 输入数据 · Input
要求 · Requirement
1) 顶层必须是数组(Array)。
2) 数组元素建议是对象(Object)。
3) 允许字段不一致,工具会自动合并所有字段作为表头。

Top-level must be an Array. Each item should be an Object. Missing keys are allowed; headers will be the union of all keys.
分隔符建议 · Delimiter tips
• 如果文本里经常出现逗号(比如地址、备注),优先用 TAB 或 |。
• 若你的 Excel 地区设置用分号分隔,选 “;”。

引号策略 · Quote strategy
• 智能加引号:只有当字段包含分隔符/换行/双引号时才加引号。
• 总是加引号:更稳定,但文件更大。

Excel 乱码 · Garbled text
若中文打开乱码,通常加 BOM 更稳。If Excel shows garbled CJK text, BOM often helps.
扁平化示例:{“a”:{“b”:1}} → 列名 a.b。Flatten example: {“a”:{“b”:1}} → header “a.b”.
为什么需要表头顺序? · Why header order matters
默认会把所有对象的 key 合并成表头,但顺序可能与你期待不同。你可以手动指定:
“name,age,city” 让输出 CSV 更适合做对比、VLOOKUP 或模板导入。

By default, headers are the union of all keys. Use header order to control column positions for analysis or imports.
Ready
3. 使用说明 · Notes
  • 输入格式要求 · Input format
    中文:本工具主要面向“数组 + 对象”这种 JSON:[{"a":1},{"a":2}]。如果你粘贴的是单个对象 {"a":1}, 请把它包成数组:[{"a":1}]
    English:This tool expects a JSON array: [{...},{...}]. If you only have a single object, wrap it: [{...}].
  • 字段不一致如何处理? · What if keys differ across rows?
    中文:不同对象缺失的字段会输出为空(或按你的空值策略输出 null / N/A)。 表头默认是“所有对象 key 的并集”。
    English:Missing keys become empty (or “null”/”N/A” depending on your setting). Headers default to the union of all keys.
  • 扁平化(Flatten)什么时候用? · When should I enable flatten?
    中文:当你的数据有嵌套对象(例如 user.profile.name)并且你希望在 Excel 里直接筛选/透视, 建议开启扁平化,它会把嵌套展开为 user.profile.name 这样的列名。
    若你不想展开,也可以关闭扁平化,此时嵌套对象会被 JSON.stringify 成一整段文本写进单元格。
    English:Enable flatten when you have nested objects and want to analyze them as separate columns in Excel. If disabled, nested objects are stringified into a single cell.
  • 数组字段如何写入? · How are arrays exported?
    中文:数组默认输出为 JSON 字符串(例如 ["a","b"]),更完整、更不容易丢信息。 如果你只是简单标签列表,也可以选择“join by comma”,输出 a,b
    English:Arrays are exported as JSON strings by default to preserve structure. Optionally, you can join by comma for simple tag-like arrays.
  • Excel 打开乱码/列错位怎么办? · Excel issues (garbled text / wrong columns)
    中文: 1) 建议选择“UTF-8 BOM”,再下载 CSV 用 Excel 打开;
    2) 列错位通常是分隔符冲突(字段里有逗号)导致,改用 TAB 或 |;
    3) 最稳的方式是 Excel 的“数据 → 自文本/CSV”导入,可以手动选择编码与分隔符。
    English: Use UTF-8 BOM, choose a safer delimiter (TAB/|), or import via Excel “Data → From Text/CSV” to select encoding/delimiter explicitly.
  • 关于 CSV 转义规则 · CSV escaping rules (important)
    中文:当字段包含“分隔符、换行、双引号”时,会自动加引号;字段内部的双引号会变成两个双引号(CSV 标准转义)。
    English:If a field contains delimiter/newline/quotes, it will be quoted. Quotes inside fields are escaped by doubling them.
  • 数据隐私提醒 · Privacy note
    中文:本工具完全在浏览器本地运行,不会上传你的 JSON 数据到服务器(除非你自己手动复制到别处)。
    English:This runs locally in your browser; your JSON is not uploaded anywhere (unless you paste it elsewhere yourself).

说明:本工具用于数据清洗与导入辅助,输出结果受输入数据结构影响。若你的 JSON 结构非常复杂(深层嵌套、数组套对象、多类型混合),建议先在数据源侧做字段规范化,再导入 Excel。
Note: Output depends on your JSON structure. For very complex nested data, consider normalizing fields at the source before importing into Excel.