Converting JSON to CSV transforms nested, structured API data into flat rows and columns for spreadsheet analysis, database imports, and reporting tools. This guide covers every method from the fastest online converter to production-ready scripts.

Convert JSON to CSV Online Free

Format Pilot data formatter converts JSON arrays to CSV instantly. Paste your JSON array, select JSON to CSV, and click Convert. Each object in the JSON array becomes one row; the keys of the first object become column headers. The output CSV is ready for Excel, Google Sheets, or any database import tool.

Convert JSON to CSV Using Python

import json, pandas as pd
with open("data.json") as f:
    data = json.load(f)
df = pd.json_normalize(data)
df.to_csv("output.csv", index=False)

pd.json_normalize() flattens nested JSON objects using dot notation for column names. A JSON key of address containing city becomes a column named address.city in the CSV. This handles any depth of JSON nesting automatically.

Handle Nested JSON in CSV Conversion

Nested JSON objects are the main challenge in JSON-to-CSV conversion. Two strategies: flatten (expand nested objects into additional columns using dot notation — better for analysis) or stringify (convert nested objects to a JSON string in a single column — preserves structure but makes content less accessible in spreadsheets). pd.json_normalize handles flattening; use df.to_json() per cell to stringify.

Convert JSON to CSV Using jq Command Line

cat data.json | jq -r "(.[0] | keys_unsorted) as $keys | $keys, (.[] | [.[$keys[]]] | @csv)" > output.csv

jq is a lightweight command-line JSON processor available on Mac, Linux, and Windows. This single command extracts headers from the first object and formats all records as CSV with proper quoting.

Convert JSON to CSV in Node.js

const { Parser } = require("json2csv");
const data = require("./data.json");
const parser = new Parser();
const csv = parser.parse(data);
require("fs").writeFileSync("output.csv", csv);

Frequently Asked Questions

What happens to JSON arrays within objects when converting to CSV?

Arrays within JSON objects are either stringified (converted to a JSON array string in one cell) or expanded (creating multiple rows, one per array element). Format Pilot converter stringifies arrays to keep one row per JSON object. Use pandas explode() to split arrays into separate rows for analysis.

How do I convert a JSON API response to CSV?

Most API responses return a JSON array of objects. Copy the response body, paste it into Format Pilot data formatter, select JSON to CSV, and click Convert. For paginated APIs that return large datasets across multiple requests, use a Python script to fetch all pages, combine the arrays, and convert the combined data to CSV in one operation.