← All guides
PRACTICAL GUIDE / DATA

How to turn JSON records into CSV without losing important details

Last reviewed: . JSON stores structured records for APIs and applications. CSV arranges values into spreadsheet columns. Converting between them is easy when every record has the same flat fields, but real exports often contain missing properties, nested objects and identifiers that must be treated as text.

Example: two records with different fields

Imagine an API sends two customer records. The second includes a city while the first does not. Here is the input JSON:

[
  {"id":"001","name":"Asha"},
  {"id":"002","name":"Ravi","city":"Udupi"}
]

FilePebble's JSON to CSV converter discovers the union of property names. It can produce:

id,name,city
001,Asha,
002,Ravi,Udupi

Here, city exists as a column even though Asha's record lacks it; the first cell is empty. Importantly, the ID 001 is represented as a JSON string, so the converter keeps those leading zeros in the exported CSV text.

Step 1: Provide a non-empty array of objects

Open JSON to CSV. Paste JSON into the input editor or use Open file to load a local .json file. The top-level value must be a non-empty array containing objects. A single object is not accepted as-is:

Not accepted: {"name":"Asha"}
Accepted:     [{"name":"Asha"}]

JSON syntax matters: keys and string values need double quotes, and trailing commas are invalid. For syntax troubleshooting, use JSON formatter & validator before converting.

Step 2: Convert and inspect the columns

Select Convert file, then review the generated CSV before using Download. Columns are collected from the keys found across all records, including optional properties. A missing or null property becomes an empty CSV cell. That means a CSV reader may not be able to distinguish “missing,” “null,” and “empty string” without extra rules from your application.

A CSV cell may need quotes—for example a city written as "Mangaluru, Karnataka". A correct CSV writer adds escaping where required. Do not strip CSV quotes manually just because the file appears more readable without them.

Step 3: Decide what to do with nested objects

Nested JSON is not automatically expanded into multiple columns. For example, a property such as "address":{"city":"Udupi"} is serialized as JSON text inside one CSV cell. Similarly, an array like "tags":["new","priority"] becomes a JSON string in a cell.

If your spreadsheet needs a separate city column, transform the original records before conversion. Otherwise the nested structure remains text that another system may need to parse. This is safer than pretending that a nested object is already a flat table.

Step 4: Protect identifiers and understand spreadsheet behavior

A CSV is plain text, but spreadsheet applications may automatically turn 001 into 1, interpret long numbers imprecisely or transform text that looks like a date. When importing a CSV, explicitly set identifier columns to Text where that option exists.

For very large numeric IDs, start with JSON string values instead of JSON numbers. The converter parses JSON using JavaScript's number handling; a number larger than its safe-integer range may already have changed before CSV export.

CSV has another subtle risk: a cell beginning with characters such as = may be interpreted as a formula by spreadsheet software. FilePebble uses formula escaping when exporting CSV to reduce this risk. Such protection can add a leading apostrophe to some cells. If you are importing into a system that requires exact original strings, review how it handles those prefixes and test a small file first.

Limits and checks before using the CSV

Need to go the other way? CSV to JSON reads a header row and retains source values as strings. Need to compare two exports? Try the CSV comparison by ID guide.

Put it into practice

Try the steps with a small sample before processing important files. Keep an original copy and review exported results.

Open JSON to CSV ↗ · Browse all FilePebble guides