JSON to CSV Converter
Flattens nested objects into columns, takes the union of every key, and escapes properly.
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 JSON | Default handling | Note |
|---|---|---|
| Objects carry different keys | Union of all keys becomes the columns | Missing cells are left empty |
Nested object {a:{b:1}} | Flattened to a column named a.b | Depth is unlimited |
Array value [1,2] | Joined into one cell with a separator | Loses the structure — unavoidable in CSV |
| Empty array or empty object | Empty cell | Distinguishable only in the source |
null | Empty cell | Indistinguishable from an empty string |
| Top-level object rather than array | Rendered as a key/value table | For 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
- Paste a JSON array of objects, or a single object.
- Choose the delimiter: comma, tab, semicolon or pipe.
- Choose whether to flatten nested objects.
- 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.
nulland 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?
{"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?
How do I stop Excel from executing a formula?
=, +, - or @ with a single quote, or export as a .txt and use the import wizard with the formula column set to text.