JSON to CSV Conversion: Tips and Best Practices
Flattening Nested Objects
CSV is flat by design — every value lives in a single cell. JSON is often deeply nested. The key challenge in conversion is flattening nested structures into columns. Dot notation is the standard approach:
// Input JSON
[
{ "name": "Alice", "address": { "city": "NYC", "zip": "10001" } }
]
// Flattened CSV columns:
// name | address.city | address.zip
// Alice| NYC | 10001
Arrays can be handled by joining values with a separator (e.g., skills.join(', ')) or by creating numbered columns (skills.0, skills.1). The right choice depends on whether you need to query individual array elements in the spreadsheet.
Handling Inconsistent Keys
Real-world JSON often has records with different keys. Record A might have email while Record B has mail. A good converter collects all unique keys across all records and fills missing values with empty cells:
[
{ "name": "Alice", "email": "a@test.com" },
{ "name": "Bob", "phone": "555-1234" }
]
// CSV with all columns:
// name | email | phone
// Alice | a@test.com |
// Bob | | 555-1234
Tip: Before converting, normalize your JSON — ensure all records share the same key structure. This avoids missing columns and makes the CSV easier to analyze.
Choosing the Right Delimiter
The default delimiter is a comma, but it breaks when your data contains commas (common in addresses, descriptions). Alternatives:
| Delimiter | Best For | Excel Compatible |
|---|---|---|
, (comma) | Simple data, no commas in values | Yes |
; (semicolon) | European locale CSV, data with commas | Yes |
\t (tab) | Complex data, code exports | Yes (.tsv) |
If values contain the delimiter, wrap them in double quotes. If values contain quotes, escape them by doubling: "He said ""hello""".
Large Datasets & Excel Compatibility
Excel has a 1,048,576 row limit and 16,384 column limit. For JSON arrays larger than ~1 million records, split into multiple CSV files or use a database import instead.
Also watch for encoding issues: Excel on Windows expects UTF-8 with BOM for proper non-ASCII character display. Add a BOM (\uFEFF) at the start of the CSV if your data contains special characters.
Convert your JSON data to CSV instantly?
Use the JSON to CSV Converter tool