JSON to CSV Converter

Convert JSON data to CSV with support for nested objects, arrays, and custom delimiters.

1
1
Rows: 0Characters: 0

Converts JSON into CSV you can open in Excel, Google Sheets or a database import β€” including nested objects and arrays. Conversion runs in your browser; the data is not uploaded.

What it accepts

An array of objects becomes one row per object. An object that contains exactly one array of objects β€” a typical API response like { "data": [ … ] } β€” converts that array. Any other single object becomes one row.

Columns are every key found in any row, in the order they first appear; a row without a key gets an empty cell. Numbers are written as they appear in the JSON, every digit kept. An item that is not an object is reported with its line; an array item fills columns 0, 1, 2 and so on.

Options

  • CSV delimiter β€” a comma by default; use ; for spreadsheets in regions that use a comma as the decimal point, or \t for tab-separated output.
  • Flatten nested objects β€” on by default: { "address": { "city": "Pune" } } becomes a column address.city. Off, nested objects are written as JSON text in one cell.
  • Arrays as JSON β€” off by default, arrays are joined with the array separator (, ), with any objects inside written as JSON; on, the whole array is written as JSON.
  • Use null for empty values β€” writes null instead of an empty cell for missing, null and empty values.
  • Quote all fields β€” wraps every value in double quotes. Without it, only values containing the delimiter, a quote or a line break are quoted, with quotes doubled inside.
  • Include header row β€” on by default.
  • Escape formulas β€” off by default. On, a cell that a spreadsheet could run as a formula gets a leading apostrophe: one starting with =, +, - or @ (or their full-width forms), a tab or a line break. Signed numbers such as -5 are left as they are. Turn it on when the JSON holds text other people typed and the file will be opened in a spreadsheet; leave it off for a database import, where the apostrophe would be stored as data.

Download saves the result as data.csv in UTF-8, each row ending with a carriage return and line feed as RFC 4180 specifies. Add BOM to download, on by default, starts the file with a byte order mark so that Excel reads accented letters, Indian scripts and currency signs correctly; turn it off for an importer that would read the mark as part of the first column name. Copy and the output shown are unchanged by either.

Examples

Nested objects and arrays

With the default options:

JSON
[
  {
    "name": "Anna",
    "address": {
      "city": "Pune"
    },
    "tags": [
      "admin",
      "dev"
    ]
  },
  {
    "name": "Ben",
    "email": "ben@example.com",
    "address": {
      "city": "Delhi"
    }
  }
]
CSV
name,address.city,tags,email
Anna,Pune,"admin, dev",
Ben,Delhi,,ben@example.com

Escaping formulas

With Escape formulas on:

JSON
[
  {
    "name": "=HYPERLINK(A1)",
    "change": "-5",
    "note": "-pending"
  }
]
CSV
name,change,note
'=HYPERLINK(A1),-5,'-pending

The formula and -pending get an apostrophe; -5 is a number and stays as written.

Formulas in CSV

A CSV cell is plain text, but a spreadsheet treats one that begins with a formula character as a formula, which can run when the file is opened (β€œCSV injection”). The characters this tool guards are the ones OWASP lists. OWASP notes the limits of any such guard: the apostrophe can show in the cell, and Excel may drop the protection once the file is saved and reopened.

Sources

Reviewed

See also