{}JSONLint.app

Paste your JSON below to convert it to CSV format:

Loading...

How JSON to CSV Conversion Works

This tool converts JSON arrays into CSV (Comma-Separated Values) format. Each object in the array becomes a row, and each property becomes a column. It's the fastest way to get JSON data into Excel, Google Sheets, or any spreadsheet application.

What JSON Structure Works Best?

The ideal input is an array of flat objects:

[
  { "name": "Alice", "email": "alice@example.com", "age": 30 },
  { "name": "Bob", "email": "bob@example.com", "age": 25 }
]

Or an object containing an array:

{
  "users": [
    { "name": "Alice", "email": "alice@example.com" },
    { "name": "Bob", "email": "bob@example.com" }
  ]
}

Handling Nested Objects

When your JSON contains nested objects or arrays, they're converted to JSON strings in the CSV output. For example:

{ "name": "Alice", "address": { "city": "NYC", "zip": "10001" } }

Becomes:

name,address
Alice,"{""city"":""NYC"",""zip"":""10001""}"

Delimiter Options

OptionUse Case
, CommaStandard CSV, works everywhere
; SemicolonEuropean locales where comma is decimal separator
TabTSV format, good for data with commas
| PipeWhen data contains commas and quotes

Common Use Cases

  • API response to spreadsheet — Export API data for analysis in Excel
  • Database export — Convert MongoDB/JSON exports to CSV for reporting
  • Data migration — Move data between systems that expect different formats
  • Quick data review — CSV is easier to scan than nested JSON

Programmatic Conversion

JavaScript

function jsonToCsv(jsonArray) {
  if (!jsonArray.length) return '';
  
  const headers = Object.keys(jsonArray[0]);
  const rows = jsonArray.map(obj => 
    headers.map(h => JSON.stringify(obj[h] ?? '')).join(',')
  );
  
  return [headers.join(','), ...rows].join('\n');
}

Python

import json
import csv
import io

def json_to_csv(json_data):
    output = io.StringIO()
    writer = csv.DictWriter(output, fieldnames=json_data[0].keys())
    writer.writeheader()
    writer.writerows(json_data)
    return output.getvalue()

Pro Tips

  • 💡 Flatten first — For deeply nested JSON, consider using our JSON Flatten tool before converting
  • 💡 Check encoding — If you see garbled characters, ensure your JSON is UTF-8 encoded
  • 💡 Large files — This tool handles files up to a few MB. For larger datasets, use a programmatic approach

Related Tools

Common Mistakes & Pro Tips

  • Nested objects and arrays don't flatten automaticallyCSV is a flat, two-dimensional format, so a value like {"address":{"city":"NYC"}} can't map to a single cell cleanly. Most converters either serialize the nested value back to a JSON string in the cell (e.g. {"city":"NYC"}) or flatten keys with dot notation (address.city). Check which behavior your output uses before importing into a tool that expects scalar columns.
  • Commas, quotes, and newlines inside values must be quoted and escapedPer RFC 4180, any field containing a comma, a double quote, or a line break must be wrapped in double quotes, and literal double quotes inside it are doubled (" becomes ""). So the value She said "hi" becomes "She said ""hi""". If a converter omits this, a single value with a comma will shift every following column and silently corrupt the row.
  • Headers come from the union of all keys, not just the first objectIf your array has objects with different shapes, the column list should be the union of every key across every row, not only the keys of the first record. Rows missing a given key get an empty cell for that column. If a converter only reads keys from the first object, later fields like a phone that only some records have will be dropped entirely.
  • null, undefined, and missing keys are not the same as empty stringCSV has no way to distinguish a JSON null from an absent key or from an empty string "" — all three usually render as an empty cell. If that distinction matters downstream (for example, NULL vs '' in a database load), CSV is lossy and you may need a sentinel value or a format like JSON Lines instead.
  • Excel may mangle CSV on open even when the file is correctA correct CSV can still look wrong because Excel auto-converts cell contents: leading zeros in ZIP codes or IDs get stripped, long numbers go to scientific notation, and strings like 1/2 or SEPT1 become dates. The CSV file itself is fine — to preserve values, import via Data > From Text/CSV and set column types to Text rather than double-clicking the file.

Frequently Asked Questions

How do I convert a JSON array of objects to CSV?

Paste or upload a JSON array like [{"id":1,"name":"Ada"},{"id":2,"name":"Linus"}]. The converter collects the union of all object keys to build the header row (id,name) and writes one CSV row per object. Values are quoted and escaped where needed, and the result is ready to download or copy.

What happens to nested objects and arrays when converting to CSV?

Because CSV cells hold a single scalar value, nested structures can't expand into rows on their own. A nested object or array is typically written into the cell as its JSON string representation, or its keys are flattened with dot notation (e.g. user.address.zip). If you need one row per element of a nested array, flatten or denormalize the JSON before converting.

How are commas and quotes inside a value handled so they don't break columns?

Any value containing a comma, double quote, or newline is wrapped in double quotes, and embedded double quotes are escaped by doubling them, following RFC 4180. For example the name Smith, John becomes "Smith, John" in the output. This keeps the field intact as one column when the CSV is parsed by a spec-compliant reader.

Can I change the delimiter from a comma to a semicolon or tab?

Comma is the default and most portable delimiter, but semicolons are common in European locales (where the comma is a decimal separator) and tabs produce TSV. If your data contains many commas, switching to a tab or semicolon delimiter can reduce the need for quoting. Whatever delimiter you choose, the receiving program must be told to use the same one on import.

Why do my leading zeros and long numbers change when I open the CSV in Excel?

That is Excel's auto-formatting, not a flaw in the CSV. Excel strips leading zeros from values like 00123 and converts 16-plus-digit numbers to scientific notation when it guesses the column is numeric. The underlying CSV text is unchanged; import through Data > From Text/CSV and mark those columns as Text to keep the original values.

Is my JSON uploaded to a server during conversion?

No. The conversion runs entirely in your browser using JavaScript, so the JSON you paste never leaves your machine and is not sent to any server. This makes it safe to convert proprietary or sensitive data. You can confirm this by opening your browser's network tab and watching that no request is made when you convert.