Spreadsheet 7 min read

JSON to CSV: Export Structured Data for Spreadsheets

APIs return JSON, but analysts work in Excel. Learn how to flatten nested JSON into clean CSV rows.

Elena Vasquez

JSON is the standard API response format. CSV is what Excel, Google Sheets, and most BI tools expect. Converting between them is a daily task for analysts and developers.

Understanding the Structure Difference

JSON supports nested objects and arrays. CSV is flat - one row per record, one column per field. Flattening nested JSON is where most manual exports fail.

Common Manual Export Pitfalls

  • Nested arrays become unreadable single cells
  • Commas inside values break column alignment
  • Null values appear as empty strings inconsistently
  • Date formats vary between systems

Pro tip: Always open CSV exports in a text editor first to verify quoting before importing into Excel.

Use Our JSON to CSV Tool

Our JSON to CSV converter flattens nested structures and handles quoting automatically. For the reverse direction, use CSV to JSON.

Excel Workflow

After converting to CSV, import into Excel with Data → From Text/CSV. Select UTF-8 encoding to preserve international characters. For direct Excel output, try Excel to CSV in reverse workflows.

Handling Nested JSON

Real API responses often contain arrays inside objects. A flat CSV can represent one level of nesting by prefixing column names (e.g., address.city, address.zip). Deeper nesting may require multiple CSV files or staying in JSON format for complex structures.

Key Takeaways

  • JSON is hierarchical; CSV is flat
  • Flatten and quote carefully to avoid broken imports
  • Validate output in a text editor before loading into Excel

Stop when the JSON is not a table

JSON to CSV works when you have a list of similar objects. If each record contains another list of unknown length, one CSV will be a mess. Split the export or keep the JSON. Quote fields that contain commas before a spreadsheet imports them.

Read one sample row in a text editor

Excel will hide the commas that broke a column. A text editor will not. If a field contains a list, you do not have one table yet. Flatten that list or keep the JSON. Dates and identifiers with leading zeros need to be text on import. The conversion runs in the browser. Check the shape before you post the CSV to a database that will guess types for you.

If one record has keys the others lack, the CSV grows a sparse column. That is normal, and it is a reason to look at the header row before you import. Empty cells and missing keys are different in JSON and similar in a sheet. Decide which you meant. Pretty-printed JSON and compact JSON convert the same if the structure matches. A trailing comma that a browser allowed in a display will still make a strict parser fail. Fix the JSON first.

Count records in the JSON and rows in the CSV, excluding the header. Those numbers should match for a flat list. If they do not, a nested list was flattened wrong or a record was skipped. Open the header and confirm every key you care about became a column. Keys that appear only on the last record are easy to miss if you only look at the first data row. Fix the export or the JSON before you load a database. A database import is annoying to undo.

If you will import into a database, decide the column types before you load. A CSV does not carry types. The database will guess, and a guess that turns an identifier into a number is painful to reverse after other tables point at it. Load into a staging table of text columns first, check the row count, then cast into the real table. That extra step is the whole point of looking at the CSV in a text editor beforehand.

Keep the JSON. The CSV is a view. If the import goes wrong, you still have the structure that the sheet flattened.

Frequently asked questions

When you have a list of similar objects. Nested lists of unknown length will not become one clean sheet.

Quoting. A comma inside a field splits one column into two if the quotes are wrong.

Not unless you import the column as text. Excel guesses types.

No. JSON to CSV runs in the browser.

Split the export, or keep the JSON. A flat sheet cannot represent every nested payload.