FixThatApp

JSON to CSV Converter Guide: Export API Data to Spreadsheets

Updated March 19, 2026

Modern APIs return data as JSON. But the people who need to analyze that data — business analysts, product managers, finance teams — live in spreadsheets. Converting JSON to CSV bridges that gap, letting you take API responses or database exports and open them directly in Excel, Google Sheets, or a Python pandas workflow.

This guide explains how the conversion works, shows a complete worked example, covers the tricky parts (nested objects, arrays within arrays), and explains when JSON-to-CSV conversion is inherently lossy.

Common Use Cases

How the Conversion Works: Flattening JSON

For a simple JSON array of flat objects, the conversion is direct: the keys of the first object become the CSV header row, and each subsequent object becomes a row. Each key's value fills the corresponding column.

The complexity arises with nested JSON. JSON supports objects within objects and arrays of objects — structures that have no direct equivalent in the flat rows-and-columns model of CSV. Converting nested JSON to CSV requires "flattening" it.

Worked Example: Flat JSON to CSV

Input JSON:

[
  {"id": 1, "name": "Alice", "email": "alice@example.com", "plan": "pro"},
  {"id": 2, "name": "Bob", "email": "bob@example.com", "plan": "free"},
  {"id": 3, "name": "Carol", "email": "carol@example.com", "plan": "pro"}
]

Output CSV:

id,name,email,plan
1,Alice,alice@example.com,pro
2,Bob,bob@example.com,free
3,Carol,carol@example.com,pro

Clean and straightforward. This opens directly in Excel or Google Sheets.

Convert Your JSON to CSV Now

Paste your JSON array and get a clean CSV file instantly — free, no login required.

Open JSON to CSV Converter

Handling Nested Objects

When an object contains nested objects, the converter flattens them using dot notation for column names. For example:

[
  {
    "id": 1,
    "name": "Alice",
    "address": {
      "city": "Portland",
      "country": "US"
    }
  }
]

Flattened to CSV:

id,name,address.city,address.country
1,Alice,Portland,US

The nested address object becomes two columns: address.city and address.country. This is lossless — all the data is preserved, just restructured.

Handling Arrays Within Objects

Arrays within JSON objects are the hardest case. Consider a user record with multiple tags:

[
  {"id": 1, "name": "Alice", "tags": ["admin", "beta-tester"]}
]

There is no clean single-row representation for this in CSV. Converters handle it one of a few ways:

For most use cases, serializing arrays to a delimited string per cell is the most practical approach when you need a quick export.

Handling Inconsistent Keys

Real-world JSON APIs sometimes return records with different keys. One object might have a phone field while another does not. A good converter uses the union of all keys it finds as the header row, and fills empty cells with blank or null values. Always check your CSV output for unexpected empty columns.

Using the Output in Spreadsheet Tools

Excel

Open Excel and use File > Open or import via the Data ribbon. When importing a .csv file, Excel shows a Text Import Wizard — confirm that the delimiter is a comma and that the encoding is UTF-8 to avoid garbled special characters.

Google Sheets

In Google Sheets, use File > Import and upload the CSV. Choose "Comma" as the separator type and "No" for "Convert text to numbers and dates" if you want to preserve values exactly as strings.

Python pandas

import pandas as pd

df = pd.read_csv('output.csv')
print(df.head())

Pandas reads CSV files natively and attempts type inference — numbers will become integers or floats, and date strings may be parsed automatically. If this causes issues, use dtype=str to load everything as strings first.

When JSON to CSV Is Lossy

CSV is a flat, two-dimensional format. JSON can represent arbitrarily complex hierarchical data. Any time you convert from JSON to CSV, you risk losing information:

Keep your JSON as the source of truth Always export to CSV from the original JSON; do not modify the CSV and try to import it back to JSON. CSV-to-JSON round-trips are lossy — especially for nested structures and typed values.

Tips for Clean Output

Summary

Converting JSON to CSV maps the keys of each object to column headers and each object to a row. Flat JSON converts cleanly. Nested objects are flattened with dot-notation column names. Arrays within objects require a strategy choice: serialize to string, expand to columns, or expand to rows. The conversion is lossy for complex structures — CSV cannot represent all of JSON's expressiveness. For a clean result, start with flat or lightly nested JSON, use consistent keys, and verify your output in a spreadsheet before distributing.