Data Formats 2026-04-16

Fix JSON to CSV Conversion Errors

Resolve JSON to CSV conversion issues: nested object handling, array flattening, special character escaping, encoding problems, and missing columns.

json to csv not working json csv conversion error csv export broken json nested to csv

Converting JSON to CSV seems simple until you hit nested objects, arrays, special characters, or inconsistent schemas. This guide covers every common conversion error.

Common errors covered

  1. 1 Nested objects produce [object Object] in CSV
  2. 2 Commas in values break CSV columns
  3. 3 Inconsistent JSON keys produce missing CSV columns
1

Nested objects produce [object Object] in CSV

Error message
CSV column shows [object Object] instead of data Nested JSON data missing from CSV output
Root cause

CSV is a flat format. When a JSON field contains an object, naive conversion just calls toString() which produces [object Object].

Step-by-step fix

  1. 1 Use our JSON to CSV tool - it automatically flattens nested objects.
  2. 2 Nested keys become dot-notation columns: address.city, address.zip.
  3. 3 Or flatten manually before conversion.
  4. 4 For deeply nested data, consider JSON Lines format instead of CSV.
Wrong
{"name": "Alice", "address": {"city": "NYC"}}
-> CSV: name,address
        Alice,[object Object]
Correct
{"name": "Alice", "address": {"city": "NYC"}}
-> CSV: name,address.city
        Alice,NYC

2

Commas in values break CSV columns

Error message
CSV columns are shifted/misaligned Importing CSV shows data in wrong columns
Root cause

If a value contains a comma and is not properly quoted, the comma is interpreted as a column delimiter.

Step-by-step fix

  1. 1 Our JSON to CSV tool automatically quotes values containing commas.
  2. 2 Check that all values with commas are wrapped in double quotes.
  3. 3 If a value contains double quotes AND commas, the quotes must be escaped: "".
  4. 4 Verify by opening the CSV in a text editor (not Excel) to see raw formatting.
Wrong
name,address
Alice,123 Main St, Apt 4
// 'Apt 4' becomes a separate column!
Correct
name,address
Alice,"123 Main St, Apt 4"
// Quoted value keeps comma as data

3

Inconsistent JSON keys produce missing CSV columns

Error message
Some rows have empty/missing columns in CSV CSV header does not match all data rows
Root cause

When JSON objects in an array have different keys, CSV conversion must handle the superset of all keys. Missing keys become empty cells.

Step-by-step fix

  1. 1 Use our JSON to CSV tool - it collects all unique keys across all objects.
  2. 2 Check that the header row contains all expected columns.
  3. 3 Missing values become empty cells (this is correct CSV behavior).
  4. 4 If keys are inconsistent, normalize your JSON schema before conversion.
Wrong
[{"name": "Alice", "age": 30}, {"name": "Bob", "email": "[email protected]"}]
// Which columns should the CSV have?
Correct
[{"name": "Alice", "age": 30}, {"name": "Bob", "email": "[email protected]"}]
-> CSV: name,age,email
        Alice,30,
        Bob,,[email protected]

Prevention Tips

  • Flatten nested JSON before CSV conversion when possible.
  • Always use our JSON to CSV tool which handles quoting, escaping, and nesting automatically.
  • For complex JSON structures, consider alternative formats: TSV, JSON Lines, or Parquet.
  • Validate the CSV output by importing it back and checking row/column counts.

Frequently Asked Questions

How should JSON arrays inside values be handled in CSV?

Arrays can be joined with a delimiter (e.g., tag1|tag2|tag3), JSON-stringified in the cell, or split into separate rows. Our tool joins arrays with a pipe | by default.

Why does Excel show garbled characters when opening my CSV?

Excel defaults to the system encoding, not UTF-8. Add a BOM (Byte Order Mark) at the start of the file, or import via Data then From Text/CSV and select UTF-8 encoding.

Can I convert CSV back to JSON?

Yes. Our JSON to CSV tool supports bidirectional conversion. The first row becomes JSON keys.

Related Error Guides

Related Tools

Still stuck? Try our free tools

All tools run in your browser, no signup required.