JSON to CSV — Complete Guide
JSON (JavaScript Object Notation) and CSV (Comma-Separated Values) are two of the most widely used data interchange formats. JSON is the dominant format for REST APIs and NoSQL databases, while CSV is universally understood by spreadsheet applications and data pipelines.
What Makes a Good JSON-to-CSV Converter?
A robust converter handles: nested objects (flattened to dot-notation keys), arrays (either stringified or expanded to rows), mixed schemas (objects with different keys — missing values become empty cells), proper RFC 4180 quoting (fields containing commas, quotes, or newlines are wrapped in double-quotes), and character encoding (UTF-8 BOM for Excel compatibility).
Nested JSON Example
Input JSON:
[{"name":"Alice","address":{"city":"New York","zip":"10001"}}]
Output CSV (flattened):
name,address.city,address.zip
Alice,New York,10001
When to Use Which Delimiter
- Comma (,) — Standard CSV, works everywhere
- Semicolon (;) — Used in European locales where comma is the decimal separator
- Tab (\t) — TSV format, best when data contains commas
- Pipe (|) — Legacy systems, log files, avoids conflicts with both comma and semicolon