How to Convert JSON to CSV (5 Methods, Free Tool Included)
Convert JSON to CSV in seconds. Five methods from drag-and-drop online tools to Python scripts. Handles nested objects, arrays, and API responses. Free converter included.

The fastest way to convert JSON to CSV takes about 3 seconds. Paste your JSON, flatten nested objects, download the file. No Python needed. No coding needed. No signup.
But JSON-to-CSV conversion gets tricky fast. Nested objects need flattening. Arrays need a strategy. Multi-key API responses need you to select the right data array. This guide covers five methods ranked by speed and complexity so you can pick the right one.
Five Methods at a Glance
| Method | Time | Difficulty | Best For |
|---|---|---|---|
| Online converter | ~3 sec | None | Quick conversions, any device |
| Python (pandas) | ~10 sec | Medium | Batch processing, automation |
| JavaScript (Node.js) | ~10 sec | Medium | Web apps, API pipelines |
| Command line (jq) | ~5 sec | Medium | Linux/Mac, scripted workflows |
| Google Sheets IMPORTDATA | ~30 sec | Low | When you want data in Sheets directly |
Method 1: Online Converter (Fastest)
Paste JSON. See table preview. Download CSV. That's it.
Our JSON to CSV converter handles this in the browser. It auto-detects array structures, flattens nested objects with dot notation, and shows a live table preview before you download. Everything runs locally. Your data never leaves your machine.
Steps:
- Go to the JSON to CSV tool
- Paste your JSON or drag-drop a .json file
- If your JSON has multiple keys (like
dataandmeta), select the array you want - Toggle "Flatten nested" to convert
address.cityinto a column - Preview the table output
- Click Download or Copy to clipboard
This handles the most common JSON structures:
- Arrays of objects
[{...}, {...}]: each object becomes a row - Single objects
{...}: becomes one row - Multi-key JSON
{ data: [...], meta: {...} }: select which key to convert - Nested objects: flattened with dot notation automatically
We tested this with a 5MB JSON file (50,000 records). It parsed and converted in under 2 seconds. For files under 1MB, the conversion is instant.
Convert JSON to CSV right now
Paste JSON or upload a .json file. Flattens nested objects. Free, no signup, runs in your browser.
Method 2: Python with pandas
If you need batch conversion, custom column mapping, or repeated automation, Python is the standard approach.
Install pandas:
pip install pandas
Basic conversion:
import pandas as pd
import json
# Load JSON
with open('data.json', 'r') as f:
data = json.load(f)
# Convert to DataFrame and save as CSV
df = pd.json_normalize(data)
df.to_csv('output.csv', index=False)
The key function is pd.json_normalize(). It handles nested objects automatically:
# Input JSON:
# [{"name": "John", "address": {"city": "NYC", "zip": "10001"}}]
df = pd.json_normalize(data)
# Columns: name, address.city, address.zip
Handling arrays inside objects:
# For JSON with arrays like {"tags": ["python", "data"]}
df = pd.json_normalize(data, sep='_')
# tags column will contain the array as a string
# To explode arrays into separate rows:
df = df.explode('tags')
When to use this: Batch processing hundreds of files, integrating into data pipelines, or when you need custom column renaming and filtering.
Method 3: JavaScript (Node.js)
For web applications or when you're already in a JavaScript environment.
const fs = require('fs');
const json = JSON.parse(fs.readFileSync('data.json', 'utf8'));
// Get headers from first object
const headers = Object.keys(json[0]);
// Build CSV
const csv = [
headers.join(','),
...json.map(row =>
headers.map(h => {
const val = row[h];
if (typeof val === 'object') return JSON.stringify(val);
if (typeof val === 'string' && val.includes(',')) return `"${val}"`;
return val ?? '';
}).join(',')
)
].join('\n');
fs.writeFileSync('output.csv', csv);
For nested JSON, flatten first:
function flatten(obj, prefix = '') {
return Object.entries(obj).reduce((acc, [key, val]) => {
const newKey = prefix ? `${prefix}.${key}` : key;
if (val && typeof val === 'object' && !Array.isArray(val)) {
Object.assign(acc, flatten(val, newKey));
} else {
acc[newKey] = Array.isArray(val) ? JSON.stringify(val) : val;
}
return acc;
}, {});
}
const flattened = json.map(item => flatten(item));
When to use this: Server-side processing in Node.js, building conversion APIs, or when your data pipeline is JavaScript-based.
Method 4: Command Line with jq
The jq tool is the standard for JSON processing on the command line. Combined with basic shell commands, it handles CSV conversion efficiently.
# Simple array of flat objects
jq -r '.[0] | keys_unsorted | @csv' data.json > output.csv
jq -r '.[] | [.[]] | @csv' data.json >> output.csv
Better approach with headers:
# Extract headers and data
jq -r '(.[0] | keys_unsorted) as $keys | $keys, (.[] | [.[$keys[]]]) | @csv' data.json > output.csv
For nested objects, flatten with jq:
# Flatten one level of nesting
jq '[.[] | . as $item |
[paths(scalars)] |
map(. as $p | {([$p[] | tostring] | join(".")): ($item | getpath($p))}) |
add
]' data.json | jq -r '(.[0] | keys_unsorted) as $k | $k, (.[] | [.[$k[]]]) | @csv' > output.csv
When to use this: Quick conversions in terminal, CI/CD pipelines, scripted data processing on Linux/Mac.
Method 5: Google Sheets IMPORTDATA
If your JSON is hosted at a URL (like an API endpoint), Google Sheets can import it directly.
Steps:
- Open a new Google Sheet
- In cell A1, use
=IMPORTDATA("https://your-api.com/data.csv")(if the endpoint returns CSV) - For JSON endpoints, use Apps Script:
function importJSON(url) {
const response = UrlFetchApp.fetch(url);
const json = JSON.parse(response.getContentText());
const headers = Object.keys(json[0]);
const rows = json.map(obj => headers.map(h => obj[h] || ''));
return [headers, ...rows];
}
When to use this: When you want live-updating data in Google Sheets from a JSON API, or when collaborators need access without downloading files.
Handling Common Edge Cases
Nested objects
Most tools flatten nested objects with dot notation:
{"user": {"name": "John", "address": {"city": "NYC"}}}
Becomes columns: user.name, user.address.city
Arrays inside objects
Three common strategies:
- Stringify:
["a","b"]becomes the literal string["a","b"]in one cell - Join:
["a","b"]becomesa;b(semicolon-separated) - First element:
["a","b"]becomes justa - Explode: each array element gets its own row
Our online converter lets you choose your preferred strategy in the settings.
Multi-key JSON (API responses)
API responses often wrap data in metadata:
{
"status": "ok",
"total": 150,
"data": [
{"id": 1, "name": "Item 1"},
{"id": 2, "name": "Item 2"}
]
}
You need to select the data key before converting. Our tool detects these structures automatically and shows a dropdown to pick the right array.
Empty values and nulls
null→ empty cellundefined→ empty cell- Empty string
""→ empty cell 0→0(preserved as a value)
JSON vs CSV: When to Use Which
| JSON | CSV | |
|---|---|---|
| Structure | Nested, hierarchical | Flat, tabular |
| Best for | APIs, configs, web apps | Spreadsheets, databases, analytics |
| Readable by | Developers | Everyone |
| File size | Larger (keys repeated) | Smaller (headers once) |
| Tools | Code editors, browsers | Excel, Sheets, any spreadsheet |
Convert JSON to CSV when:
- You need to open data in Excel or Google Sheets
- You're sharing data with non-technical people
- You need to import data into a database or CRM
- You want to sort, filter, or chart the data
Keep it as JSON when:
- You're passing data between APIs
- The data has deep nesting that would be lost in CSV
- You need to preserve data types (numbers, booleans, arrays)
Summary
For 90% of JSON-to-CSV conversions, the online converter is the fastest path. Paste, preview, download. Under 5 seconds.
For automation, batch jobs, or custom formatting, use Python with pd.json_normalize(). For command-line pipelines, jq handles it in one line.
The key challenge is always nested data. Decide whether to flatten (dot notation), stringify (keep as JSON in cells), or explode (one row per array element) before you convert.
Ready to convert?
Our JSON to CSV converter handles nested objects, arrays, and multi-key JSON automatically. Free, instant, private.