CSV vs JSON
CSV vs JSON compared — structure, nesting, size and tooling, plus free converters between CSV and JSON.
CSV is a flat, tabular format that spreadsheets and data tools love; JSON is a nested, typed format that code loves. CSV wins for rows-and-columns data; JSON wins when records have nested or varying structure.
CSV vs JSON at a glance
| CSV | JSON | |
|---|---|---|
| Structure | Flat table (rows × columns) | Nested objects & arrays |
| Types | Everything is text | Strings, numbers, bool, null |
| Size | Very compact | Larger (keys repeated) |
| Tooling | Excel, Sheets, pandas | APIs, JS, databases |
| Nesting | Not supported | First-class |
When to use CSV
Choose CSV for tabular data destined for spreadsheets or data analysis, and for the smallest possible export of flat records.
When to use JSON
Choose JSON when records nest, types matter, or the data feeds an API or application.
Tools for CSV & JSON
CSV vs JSON
如果标题中包含空格或特殊字符怎么办?
这些字符会被替换为下划线,因为 XML 元素名不能包含它们。以数字开头的标题会自动添加前缀 `_`。
需要不同的 XML 结构(用属性而非子元素表示)怎么办?
可以先用 <a class="text-brand-600 hover:underline" href="/csv-to-json">CSV to JSON</a> 将 CSV 转为 JSON,编辑该 JSON,然后使用 <a class="text-brand-600 hover:underline" href="/json-to-xml">JSON to XML</a> 并设置属性前缀(attribute prefix)。
可以让输出结果的格式更美观吗?
输出结果已经过缩进处理。如需不同的缩进方式或想要压缩(minify),可以使用 <a class="text-brand-600 hover:underline" href="/xml-formatter">XML Formatter</a>。