Home › JSON to CSV Converter

JSON to CSV Converter Online

Convert JSON arrays to CSV files instantly. Free, private, runs in your browser — no signup, no data sent to servers.

How to Convert JSON to CSV

  1. Click "Convert JSON to CSV" above to open the tool
  2. Paste your JSON array into the left panel
  3. Choose delimiter: comma (,), semicolon (;), or tab
  4. Click Convert — CSV appears in the right panel
  5. Click Download CSV or copy to clipboard

JSON Input Format

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

Handling Nested Objects

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

JSON to CSV in JavaScript

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

JSON to CSV in Python

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 Guide

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

Frequently Asked Questions

How do I convert JSON to CSV?+
Paste your JSON array into the converter and click Convert. The tool flattens the JSON into tabular rows, using the first object's keys as column headers. Each object in the array becomes a row. Download the result as a .csv file or copy to clipboard.
What JSON structure works best for CSV conversion?+
A flat array of objects works best: [{"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.
Can I open the CSV in Excel or Google Sheets?+
Yes. The generated CSV uses standard comma-separated format compatible with Excel, Google Sheets, LibreOffice Calc, and any spreadsheet tool. For Excel on Windows with special characters, use the 'Text Import Wizard' to correctly handle UTF-8 encoding.
Does JSON to CSV handle nested objects?+
The tool flattens nested objects using dot notation for column names: a field {"user":{"name":"Alice"}} becomes column user.name. For deeply nested structures, consider using the JSON Flatten tool first.
What if objects in my JSON array have different fields?+
The converter uses a union of all keys across all objects as column headers. For objects missing a particular field, the corresponding CSV cell is left empty. This handles heterogeneous arrays cleanly.
Can I convert CSV back to JSON?+
Yes. Use the CSV to JSON converter to go in the other direction. Paste or upload a CSV file and the tool converts each row back to a JSON object, using the header row as keys.

Convert JSON to CSV now

Free, private, instant. Your data never leaves your browser.

JSON to CSV Conversion Guide

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 Array → CSV

// 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

Handling Nested JSON for CSV

// Nested — needs flattening first
{"user": {"name": "Alice"}, "score": 95}

// After flattening
{"user.name": "Alice", "score": 95}

// Then CSV
user.name,score
Alice,95

CSV Special Character Handling

CaseCSV Handling
Comma in valueWrap in double quotes: "New York, NY"
Double quote in valueEscape with double quote: "He said ""hello"""
Newline in valueWrap in double quotes: "line1\nline2"
Unicode charactersUTF-8 with BOM for Excel compatibility
Empty valueLeave blank: val1,,val3
BooleanTRUE/FALSE or true/false depending on target

Convert in Python

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)

JSON to CSV Conversion: Supported Structures

Not all JSON structures convert to CSV equally well. Here are the three formats the converter handles:

  1. Array of objects (best): [{"name":"Alice","age":30},{"name":"Bob","age":25}] → 2 CSV rows
  2. Nested objects: Flattened with dot notation — address.city becomes a column
  3. Single object: Becomes a 2-column CSV (key, value)
// Input
[{"user": {"name": "Alice"}, "score": 95},
 {"user": {"name": "Bob"},   "score": 87}]

// Output CSV (nested keys flattened)
user.name,score
Alice,95
Bob,87

JSON to CSV in Code

// 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())

JSON to CSV vs JSON to Excel

Feature CSV Excel (.xlsx)
File typePlain textBinary spreadsheet
Open in ExcelYes (import)Yes (native)
Preserves typesNo (all strings)Yes (numbers, dates)
Multiple sheetsNoYes
File sizeSmallerLarger
Best forData pipelines, databasesHuman-readable reports

Also useful: JSON to YAML | JSON to XML | JSON Formatter | JSON Diff