How to Convert JSON to CSV for Excel
Last updated: · 3 min read
To review a list of objects returned by an API as a table, load it into Excel or import it into a database, you need CSV. The JSON to CSV Converter takes the keys of the first object as the header row and writes each object as one line. Values that contain commas or quotes are wrapped in quotation marks as RFC 4180 requires. If your spreadsheet uses a comma as its decimal separator, choose the semicolon option so the columns split correctly. The conversion runs in your browser.
Formula
1. The input is parsed as JSON; its root value must be an array. 2. The keys of the first object are written in order as the header line. 3. For each object, its values are read in header order; a missing key leaves the cell empty. 4. Strings and numbers are written as they are; a nested object or array is written as JSON text inside a single cell. 5. Cells that contain the delimiter, a quote or a line break are wrapped in double quotes, and each double quote inside them is doubled; rows are separated by line breaks.
This is not a mathematical formula but a tabulation algorithm. The quoting rules are defined in RFC 4180. The column order is fixed by the first object, and keys that appear only in later objects are not added as new columns.
What the inputs mean
- JSON
- The JSON text to convert. The root value must be an array of objects, for example [{...}, {...}].
- Delimiter
- The character that separates cells: comma, semicolon or tab. Choose semicolon for Excel installations that use a comma as the decimal separator.
Worked example: Converting a product array to a semicolon CSV
- Input: [{"sku":"A1","price":12.5},{"sku":"B2","price":8}] is an array of two objects. The delimiter is semicolon.
- The keys of the first object, sku and price, form the header line: sku;price.
- The values of the first object, A1 and 12.5, are written on one line.
- The second object produces the line B2;8; its price 8 is written without quotes.
Result: The output is a three-line CSV: sku;price, A1;12.5 and B2;8. Excel splits it into the right columns when semicolon is the delimiter.
How to read the result
Column order and the set of columns come from the first object, so make sure every object has the same fields. Nested objects do not fit into a flat cell, so they appear as JSON text. When you open the file in Excel, check that the encoding is UTF-8 if the data contains accented or non-Latin characters. This is general information.
Common mistakes
- Giving a single object instead of an array; the result is one header line and one data line rather than a table.
- Writing values that contain quotes without the special quoting; the quotes must be doubled and the value wrapped in quotes.
- Using a comma delimiter for text that contains commas without relying on the quoting; check that the output has quoted values.
- Opening a comma-delimited file in a locale where Excel expects semicolons, which spreads the data into the wrong columns.
- Assuming nested objects are split into their own columns; they are written as JSON text in one cell.
Frequently asked questions
What happens when the objects have different keys?
The header comes from the first object. A field missing from an object leaves its cell empty.
Can I convert a single object?
The tool expects an array. A single object gives a header line and one value line.
How do I open the CSV in Excel without broken characters?
Use the Data tab's text import and choose UTF-8 as the file origin, or save the file as UTF-8 before opening it.
Is my JSON sent to a server?
No. The conversion runs in your browser and the text is not sent to a server.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.