JSON to CSV Converter

Turn a JSON array into a CSV file, ready to open in a spreadsheet.

0 characters

Or drop a .json/.txt file onto the box above.

Delimiter

How to use

  1. Paste a JSON array: of objects (most common), or of arrays.
  2. Pick the Field separator if you need semicolon or tab instead of comma.
  3. Read the result: the first row is the header (the union of every object's keys, in the order they first appear), one data row per array item.
  4. Copy to clipboard, or Download .csv to open directly in a spreadsheet.

Turning nested JSON into flat rows

A JSON array of objects and a CSV file describe the same shape (one row per item, one column per field), but JSON allows each object to have different keys, nested objects, and arrays, none of which CSV can represent directly. This tool reconciles the two: it collects every key that appears anywhere in the array into one header row, fills in a blank for any object missing a key, and serialises a nested object or array as a JSON string inside its cell rather than dropping it. Going the other way, the CSV to JSON Converterturns a spreadsheet export back into structured JSON.

Example

This JSON array:

[
  {
    "name": "Ada Lovelace",
    "age": 28,
    "city": "London"
  },
  {
    "name": "Grace Hopper, PhD",
    "age": 85,
    "city": "New York, NY"
  }
]

becomes:

name,age,city
Ada Lovelace,28,London
"Grace Hopper, PhD",85,"New York, NY"

Options explained

Edge cases and common errors

Do the same thing in code

import csv, json, sys

rows = json.load(open("data.json"))
keys = list(dict.fromkeys(k for row in rows for k in row))
w = csv.DictWriter(sys.stdout, fieldnames=keys)
w.writeheader()
w.writerows(rows)

Python's csv.DictWriter needs the full field list up front (dict.fromkeysabove collects the same union-of-keys this tool computes automatically) and, like this tool, turns anything that isn't already a string into its str() form rather than a JSON string. Pre-serialise nested values with json.dumps first if you need this tool's exact behaviour.

JSON to CSV Converter FAQ

What if the objects don’t all have the same keys?

The header becomes the union of every key across every object, in first-seen order; a row missing a key just gets an empty cell for it. [{"a":1,"b":2},{"b":3,"c":4}] becomes a,b,c / 1,2, / ,3,4, one row per object, in the shared header order.

What happens to a nested object or array value?

It is embedded as a JSON string inside that one cell, since CSV has no native way to represent nested structure. [{"id":1,"tags":["a","b"]}] becomes id,tags 1,"[""a"",""b""]". Reopen it with the CSV to JSON Converter, and that cell comes back as a JSON-string value, not automatically un-nested.

Can I convert an array of arrays instead of objects?

Yes. [[1,2],[3,4]] becomes 1,2 / 3,4 with no header row, since there are no keys to name one from.

Why is a field wrapped in quotes in the output?

Only when it needs to be: a value containing the delimiter, a double quote, or a line break is wrapped in quotes with any internal quote doubled, following RFC 4180; that is the same rule spreadsheet software expects when opening the file.

Runs entirely in your browser: this page is a static file with no server behind it, so nothing you paste can be uploaded. Last reviewed by Parthesh Gupta. Implements RFC 4180 (CSV).