LocalToolkit
HomeData Converters › JSON to CSV Converter

JSON to CSV Converter

Flattens nested objects into columns, takes the union of every key, and escapes properly.

🔒 Runs in your browser. Nothing is uploaded — verify it in the network panel, or disconnect and try again.

CSV is a rectangle; JSON is not

Every CSV row has the same number of cells and every column has a name. JSON objects may each carry different keys, nest arbitrarily deep, and hold arrays of unknown length. Conversion is therefore a lossy simplification, and the decisions made during it are what determine whether the result is usable.

The decisions, and the defaults used here

Problem in the JSONDefault handlingNote
Objects carry different keysUnion of all keys becomes the columnsMissing cells are left empty
Nested object {a:{b:1}}Flattened to a column named a.bDepth is unlimited
Array value [1,2]Joined into one cell with a separatorLoses the structure — unavoidable in CSV
Empty array or empty objectEmpty cellDistinguishable only in the source
nullEmpty cellIndistinguishable from an empty string
Top-level object rather than arrayRendered as a key/value tableFor a single record shape

The escaping rules nothing gets to ignore

RFC 4180 requires a field to be wrapped in double quotes if it contains a comma, a double quote, a carriage return or a line feed — and any double quote inside a quoted field must be doubled. A writer that skips this produces a file that opens correctly in the producing tool and shifts every subsequent column in Excel. The inverse mistake is trimming whitespace: a leading space inside quotes is data and must be preserved.

Formula injection is a real security problem. A cell whose value begins with =, +, - or @ is executed as a formula when the CSV is opened in Excel or Sheets. A JSON field containing =cmd|'/c calc'!A1 becomes a command prompt. If you export untrusted data, prefix suspicious leading characters with a single quote or an apostrophe.

Encoding, BOM and Excel

CSV has no way to declare its encoding. Excel on Windows historically assumed the system code page, so UTF-8 files with non-ASCII characters opened as mojibake. The workaround is a UTF-8 byte-order mark — the three bytes EF BB BF at the start of the file. Do not emit it for consumption by code, because the BOM becomes part of the first column name; do emit it when a human will double-click the file.

Getting types back

CSV stores everything as text. 007, 7 and 7.0 are three different strings with no declared type. On the way back in, a JSON converter has to guess — this site's CSV reader converts strict numeric-looking values to numbers, and leaves anything with a leading zero alone so that postal codes and account numbers survive.

How to use it

  1. Paste a JSON array of objects, or a single object.
  2. Choose the delimiter: comma, tab, semicolon or pipe.
  3. Choose whether to flatten nested objects.
  4. Convert, then check the reported column list before importing.

Worth knowing

  • RFC 4180 defines quoting: commas, quotes and line breaks force double quotes.
  • A literal double quote inside a quoted field is written as two double quotes.
  • Cells beginning with =, +, - or @ execute as formulas in Excel and Sheets.
  • A UTF-8 BOM helps Excel but contaminates the first column name for parsers.

Limitations

  • Arrays inside a record cannot be represented faithfully — they are joined into one cell.
  • Field order follows first appearance, which may not match your intended schema.
  • null and empty string both become an empty cell.
  • Very wide records with hundreds of keys produce unwieldy spreadsheets.

Frequently asked questions

How do I convert nested JSON to CSV?
Flatten it with dot notation, so {"user":{"id":1}} becomes a column named user.id. Flattening is enabled by default here and can be turned off if you prefer the nested value written as compact JSON.
Why do my columns not line up in Excel?
Almost always improper quoting — a value containing a comma was not wrapped in double quotes, so Excel treated one cell as two. Correct writers always quote fields containing commas.
How do I stop Excel from executing a formula?
Prefix any cell starting with =, +, - or @ with a single quote, or export as a .txt and use the import wizard with the formula column set to text.
Why does my first column name have a strange character?
The file begins with a UTF-8 byte-order mark and your parser did not strip it. The BOM is three bytes and becomes part of whatever follows.
Related tools
CSV to JSON ConverterJSON Formatter & ValidatorJSON to YAML ConverterJSON to XML ConverterJSON MinifierYAML to JSON Converter
Keep reading
How browser-only processing worksAll Data Converters toolsEvery tool on the site