Copied!
Back
Data Tool

JSON to CSV Converter Online — Excel-Ready

Convert JSON arrays of objects to CSV format. Auto-extracts column headers from JSON keys, flattens nested objects with dot notation, escapes commas/quotes/newlines per RFC 4180, optionally prepends UTF-8 BOM for Excel compatibility. Custom delimiters (comma, tab, semicolon). Handles large datasets entirely client-side — sensitive customer data never leaves your browser.

Last updated: May 2026
json-to-csv.tool
0 characters
Paste JSON above to convert...

What is CSV and why convert JSON to it?

CSV (Comma-Separated Values) is the lingua franca of tabular data. Defined informally for decades and standardized in RFC 4180 (2005), CSV is a flat-text format where each line is a row and each row contains comma-separated values. It opens natively in Excel, Google Sheets, Numbers, every analytics tool, and every database import wizard. Its simplicity is its superpower — you can read a CSV in any text editor.

JSON is hierarchical (nested objects, arrays, mixed types); CSV is flat (rows × columns of strings). Converting between them is one of the most common data tasks in 2026:

  • API responses → spreadsheets — fetch from a JSON API, hand a CSV to your finance team.
  • Database exports → analysis — most databases export to JSON; analysts want CSV.
  • Bulk imports — migrating 10,000 records into a new system that only accepts CSV uploads.
  • Reporting — JSON event logs → CSV for stakeholders to filter in Excel.
  • Data science prep — Pandas, R, and BigQuery all happily ingest CSV; nested JSON requires preprocessing.

The conversion is conceptually simple — extract the keys, write headers, write each object as a row — but the devil is in the details: nested objects, mixed schemas, commas inside values, Unicode, and Excel's many CSV quirks.

The CSV format — RFC 4180 in plain English

The "informal" CSV spec is full of dialects, but RFC 4180 codifies the most-compatible rules. Follow these and your CSV will work in 99% of consumers:

  • Each record on its own line, terminated by CRLF (\r\n). Lone \n works in most modern parsers but RFC says CRLF.
  • Fields separated by commas. (Some "CSV" files actually use semicolons, tabs, or pipes — those are TSV/SSV, not strict CSV.)
  • Optional header line as the first record.
  • Fields containing commas, double-quotes, or line breaks must be quoted with double quotes. Smith, John"Smith, John".
  • Double-quotes inside quoted fields must be escaped by doubling them. She said "hi""She said ""hi""".
  • No trailing comma at end of row (some parsers tolerate it; many don't).
  • UTF-8 is the modern encoding. But Microsoft Excel on Windows defaults to system encoding (Windows-1252) unless you prepend a UTF-8 BOM.

Flattening nested JSON — three approaches

The hard problem in JSON→CSV is what to do with nested objects and arrays. CSV is flat; JSON isn't. Three common strategies:

1. Dot-notation flattening (default for this tool)

Walk the JSON tree, joining keys with dots. {user: {name: "Alice", address: {city: "NYC"}}} becomes columns user.name and user.address.city. Works for moderately nested data; column names get unwieldy past 3 levels deep.

2. Stringify-arrays

For arrays, serialize the entire array as a JSON string in a single cell: {tags: ["a","b","c"]}tags column with value ["a","b","c"]. Loses tabular nature but preserves data.

3. Cartesian-product expansion (one-to-many)

For arrays of objects, emit one row per array item. {user: "Alice", orders: [{id: 1}, {id: 2}]} becomes 2 rows, both with user=Alice, but different orders.id values. Useful for joining order line items to orders.

StrategyBest forTrade-off
Dot notationNested objects (configs, profile fields)Long column names; lossy on arrays
Stringify arraysMixed nested data, machine-only consumersCell contains JSON, not human-readable
Cartesian expansionOne-to-many relationships (orders → line items)Repeats parent data on every row

The Excel CSV gotchas — what trips everyone up

1. UTF-8 without BOM = corrupted accents

Open a UTF-8 CSV in Microsoft Excel on Windows: accented characters like é show up as é. The fix is a 3-byte BOM (0xEF 0xBB 0xBF) at the start of the file. Mac Excel and Google Sheets handle UTF-8 natively; Windows Excel needs the BOM. Most online JSON-to-CSV tools forget this. This one prepends the BOM by default.

2. Date columns lose precision

Dates that look like 2026-05-02 get auto-converted by Excel to its native serial number. Dates with leading zeros ("01-02-2026") might be reformatted as "1/2/2026". Workaround: prepend dates with a tab character (\t2026-05-02) or wrap in ="2026-05-02" formula syntax to force string interpretation.

3. Number formatting

Long numbers like phone numbers or credit card numbers get scientific-notation'd in Excel. 41172345678904.11723E+12. Same workaround: ="4117234567890" in the cell forces string.

4. Locale-specific delimiter conflicts

European Excel installs default to semicolon as the CSV delimiter (because comma is the decimal separator in those locales). A US-format CSV with commas will appear as a single mangled column. Workaround: use the SEP indicator: prepend the file with sep=,\n on the first line, and Excel will respect it regardless of locale.

5. Leading equals sign

Excel treats values starting with =, +, -, @ as formulas — including dangerous ones. A CSV cell containing =cmd|'/c calc'!A1 can launch the Calculator app on Windows when the user opens the file. This is CSV injection, a real attack vector. Workaround: prefix any string starting with these chars with a single tick: '=username.

JSON to CSV in 8 programming languages

JavaScript / Node.js

javascript
// Vanilla JS for simple cases
function jsonToCsv(arr) {
  const headers = [...new Set(arr.flatMap(o => Object.keys(o)))];
  const rows = arr.map(o =>
    headers.map(h => JSON.stringify(o[h] ?? '')).join(',')
  );
  return [headers.join(','), ...rows].join('\n');
}

// Or use a library: csv-stringify, papaparse, json-2-csv
import { stringify } from 'csv-stringify/sync';
const csv = stringify(arr, { header: true });

Python

python
import csv, json

with open('data.json') as f:
    data = json.load(f)

# Auto-detect headers from first object
fieldnames = list(data[0].keys()) if data else []

with open('out.csv', 'w', newline='', encoding='utf-8-sig') as f:  # 'utf-8-sig' adds BOM
    writer = csv.DictWriter(f, fieldnames=fieldnames)
    writer.writeheader()
    writer.writerows(data)

# Pandas approach for nested data
import pandas as pd
df = pd.json_normalize(data)  # auto-flattens dot notation
df.to_csv('out.csv', index=False, encoding='utf-8-sig')

jq (command-line JSON processor)

jq
# Convert array of objects to CSV
jq -r '(.[0] | keys_unsorted) as $keys | $keys, map([.[ $keys[] ]])[] | @csv' data.json

# Custom column selection
jq -r '.[] | [.name, .age, .email] | @csv' data.json

# With headers
echo '"name","age","email"'; jq -r '.[] | [.name,.age,.email] | @csv' data.json

Go

go
import (
    "encoding/csv"
    "encoding/json"
    "os"
)

var data []map[string]interface{}
json.Unmarshal(jsonBytes, &data)

f, _ := os.Create("out.csv")
defer f.Close()
f.WriteString("\xEF\xBB\xBF")  // UTF-8 BOM for Excel
w := csv.NewWriter(f)
defer w.Flush()

// Write headers
headers := []string{"name", "age", "email"}
w.Write(headers)

// Write rows
for _, item := range data {
    row := []string{
        fmt.Sprint(item["name"]),
        fmt.Sprint(item["age"]),
        fmt.Sprint(item["email"]),
    }
    w.Write(row)
}

PHP

php
$data = json_decode(file_get_contents('data.json'), true);

$fp = fopen('out.csv', 'w');
fwrite($fp, "\xEF\xBB\xBF");  // UTF-8 BOM

// Headers
fputcsv($fp, array_keys($data[0]));

// Rows
foreach ($data as $row) {
    fputcsv($fp, $row);
}
fclose($fp);

Ruby

ruby
require 'json'
require 'csv'

data = JSON.parse(File.read('data.json'))

CSV.open('out.csv', 'w', write_headers: true,
         headers: data.first.keys, encoding: 'bom|utf-8') do |csv|
  data.each { |row| csv << row.values }
end

Bash / awk

bash
# With jq + miller (if installed)
jq -r 'map([.name, .age, .email] | @csv)[]' data.json > out.csv

# Excel-friendly: prepend BOM
printf '\xEF\xBB\xBF' > out.csv
jq -r '(map(keys_unsorted) | add | unique) as $k |
       ($k | @csv), (.[] | [.[$k[]]] | @csv)' data.json >> out.csv

Excel / Power Query (no code)

excel
# Excel 365 / 2019+:
# Data tab → Get Data → From File → From JSON
# → Select your .json file
# → Power Query opens with auto-flattened columns
# → Click "Close & Load" — JSON is now a sheet

# This handles nested objects via Power Query's transformations,
# without manually flattening

Common JSON-to-CSV mistakes

  • Forgetting the BOM for Excel. The #1 reported issue. Always prepend \xEF\xBB\xBF for Windows Excel users.
  • Not escaping commas/quotes inside cells. A field Hello, world without quoting splits into 2 cells. Always use a real CSV writer, not string concatenation.
  • Mixed schema across array. Object 1 has {a, b}, object 2 has {a, c}. Naive flattening uses object 1's keys and drops c. Compute headers as the union of all keys.
  • Date / number coercion in Excel. Phone numbers as scientific notation. Dates reformatted. Pre-quote with =-syntax or tab prefix.
  • Treating null and "" the same. CSV has no null. Pick a convention: empty cell, NULL string, or distinguish via separate flag column.
  • Nested arrays serialized inconsistently. Sometimes JSON.stringify, sometimes ;-separated. Pick one.
  • CSV injection. A user-supplied field starting with = can execute formulas in Excel. Prefix with ' for safety.
  • Wrong line endings. Mixed \n and \r\n across rows. Use the platform's CSV writer to pick consistently.
  • Forgotten encoding. Windows-1252 vs UTF-8 vs ISO-8859-1. Always use UTF-8 with BOM for cross-platform compatibility.

Best practices

  • Always emit UTF-8 with BOM when the file might open in Excel.
  • Use a real CSV library, not string concatenation. The escaping rules are subtle.
  • Compute headers from the union of all keys, not just the first object's keys. Mixed schemas are common in real data.
  • Document your nested-data strategy. Dot notation? Stringify arrays? Cartesian expansion? Pick one and document so consumers know what to expect.
  • Quote dates and IDs. Excel auto-converts otherwise. Wrap in ="..." formula syntax for hard preservation.
  • Sanitize formula triggers. Prefix any string starting with =, +, -, @ with a tick to prevent CSV injection.
  • For huge datasets, stream don't accumulate. Build CSV row-by-row to avoid loading everything into memory.
  • Test the round-trip. Convert JSON → CSV → JSON and verify equivalence. Catches escaping and encoding bugs early.
  • Consider Parquet or NDJSON for large datasets. CSV's flat schema and lack of types make it a poor archive format. CSV for human consumption; binary formats for machines.

How to use the JSON to CSV converter

Convert JSON arrays of objects into CSV files for spreadsheets (Excel, Google Sheets, Numbers), data import, and analytics. The converter flattens nested objects with dot-notation, handles arrays, and quotes values containing commas or newlines correctly per RFC 4180.

Common mistakes to avoid

Best JSON to CSV converter for 2026 — what to compare

Search results for "json to csv online", "convert json to excel", and "json csv converter" return many tools but most fail on real-world JSON: they don't handle nested objects (silently dropping data), they break on JSON arrays inside object properties, they don't add a UTF-8 BOM (so Excel mangles accented characters), or they upload your data to a server. Here's how the most-used JSON-to-CSV tools compare in 2026:

ToolBrowser-onlyNested object flattenUTF-8 BOM for ExcelCustom delimiterCost
FreeDevTool JSON to CSVYesDot notation (default)Yes (toggle)Yes (, ; \t)Free
convertcsv.com/json-to-csv.htmServer-sideLimitedYesYesFree, ad-funded
json-csv.comServer-sideYesYesLimitedFree + paid Pro
npm json2csvLocal installYes (configurable)YesYesFree, OSS
Python pandas.json_normalizeLocal PythonYes (full)N/A (write_csv encoding)YesFree, OSS
jq CLI + @csv filterLocal installManualManualYesFree, OSS

How do I convert nested JSON to CSV without losing data?

Three flattening strategies handle 99% of nested JSON. Dot notation (default here): {user:{name:"Alice",city:"NYC"}} → columns user.name, user.city. Best when the nesting is a fixed schema. Stringify arrays: {tags:["red","blue"]} → column tags with value ["red","blue"]. Best when arrays are display-only (re-import preserves the JSON). Cartesian product expansion: {order:1, items:[{sku:"A"},{sku:"B"}]} → 2 rows with order=1 repeated. Best when arrays represent one-to-many relationships and you want spreadsheet-friendly rows. This converter uses dot notation by default; for the other two strategies, use jq or pandas.

Why does Excel mangle accented characters when I open my CSV?

Excel on Windows treats CSV as ANSI/Windows-1252 by default unless the file starts with a UTF-8 Byte Order Mark (BOM, bytes EF BB BF). Without BOM: café renders as café. Three fixes: 1) Enable the "UTF-8 BOM" toggle in this converter (default on) — file opens correctly in Excel for Mac, Excel for Windows, and Numbers; 2) If you control the export pipeline, write  as the first character; 3) If you can't add BOM, open Excel → Data → From Text/CSV → File Origin: 65001 (UTF-8). Modern Excel 2021+ defaults to UTF-8 detection but older Office installations don't. The BOM is the safe path.

JSON to CSV alternative to convertcsv.com — 4 reasons developers switched

  1. Browser-only, no server upload. convertcsv.com and json-csv.com POST your data to a server. API responses with PII or unreleased schema fields shouldn't leave your browser.
  2. Smart nested-object flattening. Most online tools either silently drop nested objects or stringify them as [object Object]. Dot notation produces meaningful column names for downstream spreadsheet analysis.
  3. RFC 4180 compliance with UTF-8 BOM toggle. Output works correctly in Excel, Google Sheets, Numbers, and any RFC-4180 parser without manual fix-up.
  4. No ads, no row caps. json-csv.com caps free tier at 1,000 rows; this page handles 50,000+ rows entirely in browser memory.

Pair the JSON to CSV converter with the JSON Formatter to validate the input first, the YAML to JSON Converter if your source is YAML (Kubernetes / Docker Compose), the Byte Converter for export size estimates, and the Encoding Tools hub for the broader transform toolkit.

Frequently Asked Questions

How do I convert a JSON file to CSV?
Paste your JSON array of objects into the input above. The tool automatically extracts column headers from object keys and converts each object into a CSV row. Click "Download CSV" to save the file. The JSON must be an array like [{"name":"Alice"},{"name":"Bob"}]. Single objects are wrapped in an array automatically.
Can I convert nested JSON to a flat CSV?
Yes. When "Flatten nested objects" is checked, nested objects are flattened using dot notation. For example, {"user":{"name":"Alice"}} becomes a column user.name with value "Alice". Nested arrays are serialized as JSON strings in the CSV cell.
What is the difference between JSON and CSV?
JSON is a hierarchical format supporting nested objects, arrays, and typed values (strings, numbers, booleans, null). CSV is a flat tabular format with rows and columns — everything is a string. JSON is ideal for APIs and complex data; CSV is better for spreadsheets, databases, and tabular analysis. Converting between them often requires flattening or restructuring.
How do I open JSON data in Excel?
Convert your JSON to CSV first, then open the CSV in Excel — it auto-maps columns. Alternatively, Excel 2016+ has Power Query (Data → Get Data → From JSON) that imports JSON directly with transformation options. Google Sheets can also import CSV files via File → Import.
Is my data safe during conversion?
Yes. All conversion happens in your browser using JavaScript. No data is uploaded, stored, or logged on any server. You can safely convert sensitive API responses, database exports, or confidential datasets.

Browse all 50 free developer tools

All tools run in your browser, no signup required, nothing sent to a server.