JSON to CSV converter

JSON to CSV conversion writes one row per object and one column for every distinct property name.

Features

  • All keys includedColumns are collected from every object, not only the first.
  • Formula protectionText starting with = + - or @ is prefixed so spreadsheets do not run it.
  • Runs on your deviceYour data is processed in the browser and is never uploaded.

How to use the JSON to CSV converter

  1. Paste an array of objects.
  2. Keep formula protection on if the file will be opened in a spreadsheet.
  3. Download the CSV.

Nested data

CSV is flat. Nested objects and arrays are written into a single cell as JSON text.

Large integers

Numbers too large to represent exactly are reported instead of being silently rounded.

Convert JSON to CSV in JavaScript

const keys = [...new Set(rows.flatMap(Object.keys))];
const cell = (v) => `"${String(v ?? '').replaceAll('"', '""')}"`;
const csv = [keys, ...rows.map((r) => keys.map((k) => r[k]))].map((r) => r.map(cell).join(',')).join('\n');

Frequently asked questions

Can I convert a single object?

Yes. It produces one row.

Why is there an apostrophe before some values?

That is formula protection. Untick it to keep values unchanged.

Which separator is used?

A comma.

Related tools