CSVFormat CSV Converter

JSON to CSV: Columns, Nesting, and Cells a Spreadsheet Will Run

CSVFormat — CSV Formatter & Converter Guides · Updated 2026-10-30 · All guides

JSON is a tree and CSV is a grid, so the conversion has to make three decisions: which columns exist, what to do with values that are not scalars, and which cells need quoting. The JSON to CSV converter makes each of them visibly.

Columns are a union

Objects in an array do not have to share keys. Reading only the first object's keys silently drops a field that first appears in row 40. The converter collects the keys of every object in first-seen order, and writes an empty cell where a row lacks one:

[{"id":1,"name":"a"},{"id":2,"role":"ops"}]
id,name,role
1,a,
2,,ops

null and a missing key both become an empty cell. CSV has no way to say the difference, so if it matters, do not use CSV.

Nested values are JSON text, not flattened

An object or array inside a row cannot be a cell. The converter writes it as JSON text in one quoted cell and reports a count, so you can decide whether to flatten first. Dotted-path flattening (user.name) is a different, lossy choice with its own collisions ({"a.b":1} versus {"a":{"b":1}}), which is why it is not done silently.

Quoting is minimal and exact

Per RFC 4180 a field must be quoted if it contains the delimiter, a double quote, or a line break, and embedded quotes are doubled. The converter also quotes fields with leading or trailing whitespace, because many parsers trim unquoted ones.

ValueWritten
Connor, John"Connor, John"
say "hi""say ""hi"""
two + newline + lines"two newline lines"
pad" pad"

Cells that start a formula

A string cell beginning with =, +, -, @, tab or carriage return can be evaluated as a formula when the file is opened in a spreadsheet. The converter does not rewrite your data; it counts those cells and tells you. Plain negative numbers are not flagged. The full discussion, including mitigations, is in CSV formula injection.

Choosing delimiter and line endings

Semicolon is the usual choice for locales where the comma is the decimal separator, and tab survives most pasted text. RFC 4180 specifies CRLF; LF is accepted almost everywhere. The converter defaults to LF and offers CRLF.

Round trip

The output is read back correctly by this site's own scanner, including commas, quotes and embedded newlines. That is pinned by the repository test suite rather than asserted here.

Developer Sponsor / Partner
Copied to clipboard!