Convert JSON arrays to CSV files instantly. Free, private, runs in your browser — no signup, no data sent to servers.
The converter expects a JSON array of objects. Each object becomes a CSV row:
[
{ "name": "Alice", "age": 30, "city": "New York" },
{ "name": "Bob", "age": 25, "city": "London" },
{ "name": "Carol", "age": 35, "city": "Tokyo" }
]
Output CSV:
name,age,city Alice,30,New York Bob,25,London Carol,35,Tokyo
Nested objects are flattened using dot notation:
[
{
"name": "Alice",
"address": { "city": "New York", "country": "USA" }
}
]
Becomes:
name,address.city,address.country Alice,New York,USA
Need to convert JSON to CSV programmatically? Here is a simple function:
function jsonToCSV(data, delimiter = ',') {
if (!data.length) return '';
const headers = Object.keys(data[0]);
const escape = val => {
const str = String(val ?? '');
return str.includes(delimiter) || str.includes('"') || str.includes('\n')
? `"${str.replace(/"/g, '""')}"` : str;
};
const rows = data.map(row => headers.map(h => escape(row[h])).join(delimiter));
return [headers.join(delimiter), ...rows].join('\n');
}
const csv = jsonToCSV([
{ name: 'Alice', age: 30 },
{ name: 'Bob', age: 25 }
]);
// name,age
// Alice,30
// Bob,25
import json, csv, io
def json_to_csv(json_data):
data = json.loads(json_data) if isinstance(json_data, str) else json_data
output = io.StringIO()
writer = csv.DictWriter(output, fieldnames=data[0].keys())
writer.writeheader()
writer.writerows(data)
return output.getvalue()
json_str = '[{"name":"Alice","age":30},{"name":"Bob","age":25}]'
print(json_to_csv(json_str))
| Delimiter | Use When |
|---|---|
| Comma (,) | Standard CSV — works with Excel (US), Google Sheets, Python csv module |
| Semicolon (;) | European Excel versions (which use comma as decimal separator) |
| Tab (\t) | TSV format — best when data contains commas (e.g. addresses) |
| Pipe (|) | When data contains commas and semicolons |
[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]. Nested objects can be flattened (e.g., address.city becomes a column). Arrays within objects are serialized as JSON strings in the CSV cell.{"user":{"name":"Alice"}} becomes column user.name. For deeply nested structures, consider using the JSON Flatten tool first.Free, private, instant. Your data never leaves your browser.
JSON arrays of objects map perfectly to CSV rows. Each object key becomes a column header, and each object's values fill the row. Nested objects require flattening first.
// JSON Input
[
{"id": 1, "name": "Alice", "city": "London", "score": 95},
{"id": 2, "name": "Bob", "city": "Paris", "score": 87},
{"id": 3, "name": "Carol", "city": "Tokyo", "score": 92}
]
// CSV Output
id,name,city,score
1,Alice,London,95
2,Bob,Paris,87
3,Carol,Tokyo,92
// Nested — needs flattening first
{"user": {"name": "Alice"}, "score": 95}
// After flattening
{"user.name": "Alice", "score": 95}
// Then CSV
user.name,score
Alice,95
| Case | CSV Handling |
|---|---|
| Comma in value | Wrap in double quotes: "New York, NY" |
| Double quote in value | Escape with double quote: "He said ""hello""" |
| Newline in value | Wrap in double quotes: "line1\nline2" |
| Unicode characters | UTF-8 with BOM for Excel compatibility |
| Empty value | Leave blank: val1,,val3 |
| Boolean | TRUE/FALSE or true/false depending on target |
import json, csv
with open("data.json") as f:
data = json.load(f)
with open("output.csv", "w", newline="", encoding="utf-8") as f:
if data:
writer = csv.DictWriter(f, fieldnames=data[0].keys())
writer.writeheader()
writer.writerows(data)
Not all JSON structures convert to CSV equally well. Here are the three formats the converter handles:
[{"name":"Alice","age":30},{"name":"Bob","age":25}] → 2 CSV rowsaddress.city becomes a column// Input
[{"user": {"name": "Alice"}, "score": 95},
{"user": {"name": "Bob"}, "score": 87}]
// Output CSV (nested keys flattened)
user.name,score
Alice,95
Bob,87
// Node.js with json2csv
const { Parser } = require('json2csv');
const data = [{"name":"Alice","age":30},{"name":"Bob","age":25}];
const parser = new Parser({ fields: ['name', 'age'] });
const csv = parser.parse(data);
// Output: "name","age"\n"Alice",30\n"Bob",25
# Python with csv module
import csv, json, io
data = [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]
output = io.StringIO()
writer = csv.DictWriter(output, fieldnames=["name", "age"])
writer.writeheader()
writer.writerows(data)
print(output.getvalue())
| Feature | CSV | Excel (.xlsx) |
|---|---|---|
| File type | Plain text | Binary spreadsheet |
| Open in Excel | Yes (import) | Yes (native) |
| Preserves types | No (all strings) | Yes (numbers, dates) |
| Multiple sheets | No | Yes |
| File size | Smaller | Larger |
| Best for | Data pipelines, databases | Human-readable reports |
Also useful: JSON to YAML | JSON to XML | JSON Formatter | JSON Diff