How to convert nested JSON to CSV
Published and reviewed · Based on the current LocalShift implementation
For an array of records, flatten nested objects into named columns and decide explicitly how arrays should be represented. LocalShift uses dotted column names and keeps arrays as JSON text in one cell.
Start with the records, not the API envelope
An API response may wrap its records inside a data or results property alongside paging information. Copy the records array into the converter when you want one row per record. Pasting the whole wrapper treats it as one object; a nested array remains a single cell.
Try the JSON to CSV tool with the example below. Use a comma separator and keep the header enabled. No file upload is involved.
[{"user":{"id":"001","name":"Alex"},"tags":["new","vip"]},
{"user":{"id":"002","name":"Sam"},"active":true}]Read the column mapping
The user object becomes user.id and user.name columns. The tags array stays serialized JSON, including its brackets. The active field is included even though it is missing from the first record. Missing values and explicit null become empty cells, so CSV cannot distinguish those cases in this output.
A literal key named user.id alongside a nested user.id path would create an ambiguous column. LocalShift rejects that collision instead of choosing a value silently.
user.id,user.name,tags,active
001,Alex,"[""new"",""vip""]",
002,Sam,,trueChoose how to handle arrays before exporting
If your destination needs one row per tag, reshape the records before using this tool. Automatically expanding several independent arrays could multiply rows and create misleading combinations. The current converter deliberately keeps arrays in their original record.
Reversing the CSV back to JSON does not reconstruct nested objects. Column names such as user.name remain literal keys, and JSON text in an array cell remains a string. Keep the original JSON if you need its hierarchy.
Protect identifiers and review the result
Quote long IDs in the source JSON. Unquoted integers outside JavaScript's safe range are rejected, and ordinary decimal values use JavaScript precision. When opening the CSV in a spreadsheet, import ID columns as Text to prevent the spreadsheet from dropping zeros.
Spreadsheet-safe mode may add an apostrophe to formula-like text cells. Keep it enabled for untrusted spreadsheet-bound data, and review any downstream transformations. Verify row count and important fields before using the export.
References
General format references; LocalShift-specific behavior is documented and tested separately.