plain/devtools home

JSON to CSV converter

Paste an array of JSON objects and get a CSV file with correct quoting. Nested objects become dotted columns. Everything stays in this tab.

tool 16 of 21 []
all shortcuts ?

json-csvsampless sample · c copy

never leaves your browser

How to use it

  1. Paste a JSON array of objects, for example the body of an API response. A single object becomes a one-row file.
  2. Columns are the union of all keys, in the order they first appear. A row that lacks a key gets an empty cell.
  3. Nested objects are flattened into dotted column names such as address.city. Arrays are kept whole and written as JSON text in one cell, because there is no single right way to spread an array across columns.
  4. Choose the delimiter your spreadsheet expects (semicolon is common where the decimal separator is a comma). Tick formula protection if the data will be opened in Excel or Sheets and may contain untrusted text.

What the CSV rules actually are

RFC 4180 is the closest thing CSV has to a standard. It says records are separated by CRLF, a field must be enclosed in double quotes if it contains a comma, a double quote or a line break, and a double quote inside a quoted field is written as two double quotes. The RFC is informational, and real files vary, so this tool lets you choose a different delimiter and LF line endings.

Spreadsheet programs treat a cell that starts with =, +, - or @ as a formula. Untrusted text in those cells is known as CSV injection or formula injection. OWASP recommends prefixing such cells so they are read as text. The protection option here prepends a single quote to risky cells; it changes your data, so it is off by default.

JSON null becomes an empty cell, true and false become the words true and false, and numbers are written as JavaScript prints them. Very large integers lose precision in JSON.parse before this tool sees them.

How JSON values become CSV cells

JSON valueCSV cellNote
"text"textQuoted only if it contains the delimiter, a double quote or a line break
"He said \"hi\"""He said ""hi"""Quotes doubled, field enclosed (RFC 4180)
42, 3.542, 3.5No locale formatting
true, falsetrue, falseLowercase words
null, missing key(empty)Missing keys add a column and leave other rows empty
{"a":{"b":1}}column a.b = 1Flatten option on; off writes the object as JSON text
[1,2,3]"[1,2,3]"Arrays stay whole as JSON text
=SUM(A1)'=SUM(A1)Only with formula protection on

The table describes this tool. Other converters make different choices for arrays and nested objects.

Examples

Select an example to load it into the tool.

  • Flat records[{"id":1,"name":"Ada","role":"admin"},{"id":2,"name":"Lin","role":"dev"}]
  • Nested + quoting[{"id":1,"user":{"name":"O'Neil, Pat","tags":["a","b"]},"note":"He said \"hi\""},{"id":2,"user":{"name":"Lin"},"extra":true}]
  • Formula-looking text[{"name":"=HYPERLINK(\"http://example.com\")","qty":3},{"name":"+1 555","qty":1}]

Frequently asked questions

Why are my arrays one cell?

An array can have a different length in every row, so spreading it across columns gives ragged results. The array is written as JSON text in one cell so no data is lost. Flatten it in your source if you need columns.

Why does Excel show my accented text wrongly?

Excel often assumes a legacy encoding for CSV files without a byte order mark. If accents break, import the file with UTF-8 selected, or open it through Data, From Text/CSV.

What is CSV injection?

If a cell starts with = + - or @, a spreadsheet may run it as a formula when the file is opened. Turn on formula protection when the data includes text from users you do not control.

Is my JSON uploaded?

No. Conversion and the download both happen in this tab. The test suite fails the build if this tool contains a network call.

Can it handle an object of objects?

This tool expects an array of objects or a single object. For {"a":{...},"b":{...}}, wrap the values in an array first, or add the keys as a field.

Sources

Related tools

esc
↑↓ move↵ open? all shortcuts

Keyboard shortcuts

Cmd or Ctrl shortcuts always work.
Everywhere
Everywhere
Open the command palette
CtrlK
Open the palette (outside a text field)
/
Show these shortcuts
?
Toggle light and dark theme
t
Go home
gh
Go to all tools
gt
On a tool page
On a tool page
Run the main action
Ctrl↵
Copy the output
c
Load the next sample
s
Focus the input
i
Leave a text field
Esc
Previous or next tool
[]
In the palette
In the palette
Move the selection
↑↓
Open the selected item
↵
Close
Esc