toolbench.onlineby Valkyron Labs

Converters

JSON to CSV

Turn a JSON array of records into a spreadsheet, flattening nested fields into columns so the sheet has the delimiter and the fields you need.

JSON to CSV

Convert a JSON array of objects to CSV.

Ready to run. Input limit: 1 MB characters.

CSV output

—

Output actions

Ready to copy output once your result appears.

Dot paths for objects, JSON text for arrays

JSON to CSV reads JSON input (array of objects) and writes CSV output. Flatten nested objects starts checked. Output delimiter starts on Comma (,). Columns (comma-separated, blank = all) starts empty, which keeps every key in first-seen order. Convert to CSV runs the export. Load sample fills two address objects and does not convert. Reset clears the box and the result and leaves the checkbox, the delimiter, and Columns as they are. Copy output and Download output use the latest CSV. The download file is json-to-csv.csv.

How to flatten an array into CSV

  1. 1Paste a non-empty JSON array of objects, or press Load sample. The sample is Alice in Paris and Bob in Berlin, each with an address object. A bare object, a scalar, or [] is rejected.
  2. 2Leave Flatten nested objects checked when you want address.city. Uncheck it when the cell should hold the object as JSON text. Type Columns only when you want a subset or a different order. Blank means every key.
  3. 3Choose Output delimiter, then press Convert to CSV. A success says Converted successfully. Changing the checkbox or Columns does not rerun. Editing the JSON box clears the previous CSV. Press Convert to CSV again.

What it is good for

  • • Turning the nested sample into name and address.city without writing a script.
  • • Forcing column order with city,name when the sheet's importer is picky about the header.
  • • Keeping a tags array as one JSON cell instead of inventing extra rows.

Example

Input

[{"name":"Alice","address":{"city":"Paris"}},{"name":"Bob","address":{"city":"Berlin"}}]

Output

name,address.city
Alice,Paris
Bob,Berlin

Flatten nested objects is checked and Columns is blank. address is an object with a city key, so the header is the dot path address.city. Bob's row follows Alice's. Press Load sample, then Convert to CSV.

What a nested object becomes

The box must parse as JSON and must be an array with at least one element. Every element must be a plain object. A number, a string, null, or a nested array as a row stops with Input must be a non-empty JSON array of objects. With flattening on, each own key is walked. A value that is a non-null object, not an array, and not empty becomes more columns. The path joins keys with dots, so address then city is address.city. An empty object is not walked, because it has no keys. It stays one cell whose text is {}. An array is never walked. It stays one cell whose text is JSON.

Keys are collected in the order they are first seen across the rows. The sample meets name first, then address.city, so the header is name,address.city even though you might have expected city to lead. A later row that introduces a new key appends a column. A later row that omits a key leaves that cell empty. null is also an empty cell. The CSV cannot show which empty cell was null and which key was absent. A cell that contains the delimiter, a quote, or a line break is wrapped in double quotes, and each quote inside the cell is doubled. That is why a tags value of ["a","b"] is written as a quoted cell with doubled quotes.

Flatten nested objects, Columns, and Output delimiter

Flatten nested objects starts checked. Uncheck it and convert the sample again and the header is name,address. Alice's second cell is the JSON object {"city":"Paris"} with its quotes doubled inside a CSV quote. Use that form when the next step must see the object intact. Use the dot path when a spreadsheet column should be the leaf. The checkbox does not remember a previous conversion. The result on screen stays until the next successful click, and a failed click clears it.

Columns is split on commas, then each piece is trimmed. city,name on a flat row that has those keys writes the header city,name and the values in that order. A name that does not exist, a repeated name, or a blank piece after the split stops with Select unique columns that exist in the input. A key that itself contains a comma cannot be named in this box, because the comma is the separator. Leave Columns blank to keep that key with the others. Output delimiter offers comma, semicolon, tab, and pipe. The sample's cities have no comma, so the comma file needs no extra quotes. A city value that contained a comma would be quoted. Semicolon is the right choice when the sheet you will open already expects it. The guide Convert nested JSON to CSV without losing fields walks a larger record through this same choice.

When a spreadsheet is the destination

Use this page when you already have a JSON array and the next person will open a sheet. The sample is the small version: two people, one nested city, two columns. A wider export is the same rule, up to the 1,000,000 character input limit. Past that, the message is Input exceeds the 1 MB character limit. Split large files into smaller batches. An empty box says Enter an input first. The download is json-to-csv.csv, which is the same text as CSV output.

The reverse direction, a sheet that should become records, is CSV to JSON. A file whose only problem is the separator, semicolon versus comma, is the CSV delimiter converter. An INSERT statement is CSV to SQL, which reads CSV rather than JSON. This page will not quote a table name or emit VALUES. If the array is still wrapped in a string full of backslashes, unwrap it before pasting. Flattening does not parse a string that merely looks like an object.

Arrays, a path collision, and a name that contains a comma

Arrays stay in one cell on purpose. Expanding them into extra rows would multiply the record, and the page does not guess which array is the one to expand. [{"name":"Ada","tags":["a","b"]}] with flattening on is a header name,tags and a second cell that is the JSON array, quoted because of the commas and the quotes. An empty object in a field named meta stays the two characters {} and does not become columns. A collision is a hard error. [{"a":{"b":1},"a.b":2}] with flattening on stops with Flattened column collision: a.b. Use nested JSON cells instead. Uncheck Flatten nested objects if you need both the object and the dotted key. The page will not silently keep one and drop the other.

Missing keys and null look the same in the sheet. [{"name":"Ada"},{"name":"Bea","city":"Oslo"}] is name,city, then Ada with an empty city, then Bea,Oslo. [{"name":"Ada","city":null}] is also an empty city. If a consumer must tell those apart, do not flatten that field away. Put the column list you want in Columns so a stray key cannot appear just because one row had it. Duplicate names in Columns are rejected, and so is a column you misspelled. The first row of the file is always the header. There is no switch that omits it. Numbers and booleans are written with their JSON spelling, so true is the letters t-r-u-e and 1 is the digit. They are not retyped as spreadsheet formulas.

Rules and limitations

Input is a non-empty array of objects, at most 1,000,000 characters. Flattening writes dot paths for non-empty objects. Arrays and empty objects stay JSON text in one cell. A path that collides with another key is an error.

Blank Columns keeps first-seen key order. A comma list must name unique keys that exist. Null and missing keys are empty cells. Cells with the delimiter, a quote, or a break are quoted, and quotes are doubled. The download file is json-to-csv.csv.

Common problems

If Convert to CSV says the input must be an array of objects, wrap a single object in [] or remove a row that is a scalar. [] and a bare object both fail.

If a dotted header overwrote a field you still need, the path collided. Uncheck Flatten nested objects, or rename a key. A comma inside a key cannot be selected in Columns. Leave Columns blank.

Frequently asked questions

Are arrays expanded into extra rows?

No. An array stays JSON text in one cell. The page does not invent a row per element.

What happens to a key that only some rows have?

It becomes a column, placed where it was first seen. Rows that lack it get an empty cell, the same as an explicit null.

Why did address.city collide?

Flattening built the path address.city and the row also had a key literally named address.city. Uncheck flattening, or rename one of them.

Does changing Columns update the CSV by itself?

No. Press Convert to CSV again. Editing the JSON box clears the previous result. Changing only the checkbox leaves the old CSV until the next click.

Is my input uploaded or saved?

This tool processes input in your browser and does not save its input or output to local storage. Copy and download are user actions. The site uses analytics for page and action metadata and may use ads and production error reporting; see the Privacy Policy for those services.

About this tool

Maintained by Toolbench. For large or deeply nested files, split the input into smaller batches and verify representative results before using them in an import or application. Report reproducible problems through Contact.

Guides

Next steps

Related tools

Continue the workflow with nearby tools for formatting, publishing, debugging, or follow-up checks.

Trust

Policies, contact, and answers

Clear pages for how Toolbench works, what we collect, and how to reach us.