ToolsTray

Star a tool to keep it here.

Smart JSON to CSV Converter (and back)

JSON to CSV with the header row built from your keys, or CSV back to JSON with numbers, booleans and nested objects restored.

Open a file instead

Drag and drop a .json or .csv file here

Opening a file fills the pane, sets the Direction and converts it, in this tab.

CSV

The converted file lands here.

A header row from the keys, then one line per row.

Direction

What the round trip changes

—cells come back different

How to use

  1. Set the Direction to match what you're pasting, JSON → CSV or CSV → JSON. The swap between the panes sends the result back the other way.
  2. Paste into the left well, or open a .json or .csv file, which fills the well, picks the Direction and converts on the spot.
  3. Leave the Delimiter on Auto unless whatever reads the file next insists on a particular character. Custom takes up to three characters for the odd pipeline that wants something unusual.
  4. Read the count under the panes, then press Copy output or Download it as data.csv or data.json.

How this works

Turning JSON to CSV is usually about an API that gave you an array and a person who wants a spreadsheet. The reverse turns up when a colleague's export has to become something a script can loop over. Paste either shape into the left well, set the Direction, and the converted copy builds itself on the right as you type. Opening a .json or .csv file fills the well, sets the Direction from the file and converts it in one go, and under the panes the page reads the result back and counts every cell that would not come home the same.

The Delimiter dropdown starts on Auto, and Auto is the setting worth leaving alone. On the way to CSV it reads every cell and takes the first separator that appears in none of them, working through comma, semicolon, tab, then pipe, and it says so under the result whenever it had to move off the comma; a cell that still holds any of those characters is quoted either way, so the file reads back whatever a spreadsheet guesses. Pin the dropdown to one character instead and a value already containing that character stops the run, with the row indices listed up to fifteen of them so you know where to look. In the other direction Auto lets Papa Parse sniff the separator out of the file and tells you which one it found.

Nesting has nowhere to go in a flat table, so an object or array sitting inside a record is written into its own cell as JSON text with the inner quotes doubled. Read that CSV back and a cell becomes a number, a boolean or an object only when it prints back as exactly the text it was, so 42 and true and the nested text come back as values while 1.10, 007 and a twenty-digit order number stay as they were written. A card for each column that changes type lets you set it to Text or Number instead. Keys don't have to match across your records either. The header row is the union of every key in the order they first appear, and a record missing one of them gets an empty cell in that column.

Good to know

  • The input has to be one JSON array. A bare object, a wrapped payload like {"results": [ ... ]}, and NDJSON with one object per line all come back with an error instead of a result. Lift the array out of the payload first, or bracket your newline-delimited objects and put commas between them.
  • What comes out is text, not a workbook. Excel opens it happily, but if someone specifically asked for an .xlsx, run the CSV through the CSV to XLSX converter afterwards.

Frequently asked questions

Why did my CSV come out with semicolons instead of commas?

Because a comma was already sitting inside one of your values, probably an address or a description. Auto mode moved on to the next separator so the file needs less quoting, and the line under the result tells you which one it picked. Choose Comma from the dropdown if you'd rather have the quoting.

What happens to a nested object inside a record?

It becomes JSON text in a single cell, under a column named after its key. An address object with a city and a postcode inside it lands as one cell holding the whole thing, quotes doubled so the CSV stays valid. Converting that file back reassembles the object.

Do numbers stay numbers when I convert CSV back to JSON?

A cell comes back as a number or a boolean only when it prints back as exactly its own text, so 42 and true come back typed while 007, 1.10 and a twenty-digit id stay strings rather than losing a zero or a digit. The column cards let you force a column to Text or Number. The one thing a round trip won't give you back is null, which leaves as an empty cell and returns as an empty string, and the page counts every such cell.

My objects don't all have the same keys. Will the columns line up?

They will. The header is every key found across the whole array, ordered by where each one first showed up, and any record without a given key gets an empty cell there. Nothing is dropped, so a late key that only appears in the last object still earns its own column.

Can I paste JSON Lines or NDJSON?

Not as it stands. One object per line isn't valid JSON on its own, so the parse fails before conversion starts. Wrap the lot in square brackets and put a comma at the end of each line and it goes through fine.

It says my delimiter appears in a value at index 3. What do I do?

That message comes up when you've pinned the delimiter and some values already contain it. Switch back to Auto and let it choose a clean separator, or go clean those values. The error lists the row indices, up to fifteen of them, with a count of how many more there were.

What if my JSON array holds arrays instead of objects?

Each inner array becomes a row and there's no header, because there are no keys to name the columns with. An array of plain strings or numbers is handled too and comes out as a single column, one value per row.

What name does the downloaded file get?

data.csv or data.json, depending on the direction, whatever the file you opened was called. Rename it once it lands. The copy button next to Download is usually quicker when the result is heading straight into an editor.

Can I use a separator that isn't in the dropdown?

Pick Custom and a small box appears next to the dropdown, taking up to three characters. It works reading as well as writing, so a file split on some in-house separator can come back as JSON the same way.

Missing something in Smart JSON to CSV Converter (and back)? Suggest a feature →

Tell someone who needs this.