How to Convert JSON to CSV

How to Convert JSON to CSV

You have a JSON response from an API and you need it in a spreadsheet. Converting JSON to CSV is mostly a matter of mapping a list of records to rows, and you can do it in your browser in seconds. Here is how the conversion works and how to handle the tricky parts.

How JSON to CSV mapping works

CSV is a flat, two-dimensional grid: rows and columns. JSON is a nested tree. The conversion works cleanly when your JSON is an array of objects, because each object becomes one row:

  • Each object in the array is a row of data.
  • The object keys become the header row (the first line of the CSV).
  • The matching values fill the cells under each header.

So [{"name":"Ada","role":"dev"},{"name":"Lin","role":"design"}] becomes a header row of name,role followed by two data rows. If your JSON is a single object rather than an array, it converts to one header row and one data row.

Nested objects, arrays, and missing keys

Real API responses are rarely flat, so a good converter has to deal with structure that does not fit a grid.

  • Nested objects are flattened using dot notation. A key like address holding {"city":"Pune"} becomes a column named address.city.
  • Nested arrays have no natural column layout, so they are usually stringified back into JSON text inside a single cell, for example ["a","b"] stays as ["a","b"].
  • Missing keys are normal when records differ. If one object has an email key and another does not, the converter still creates the email column and leaves an empty cell for the record that lacks it.

The JSON to CSV Converter scans every object first so the header row covers every key that appears anywhere in the array, not just the keys in the first record.

Escaping commas, quotes, and newlines

CSV uses commas to separate fields, so any value that contains a comma would break the columns if written as-is. Proper CSV handles this with quoting:

  • A value containing a comma, a quote, or a newline is wrapped in double quotes.
  • A double quote inside a value is escaped by doubling it, so 6" pipe becomes "6"" pipe".
  • A newline inside a value stays inside the quotes and does not start a new row.

This is the part people most often get wrong when hand-rolling a converter, and it is exactly why using a tested tool saves you from corrupted spreadsheets.

Convert your JSON in three steps

  1. Open the JSON to CSV Converter and paste your JSON array.
  2. Let it flatten nested fields and build the header row from your keys.
  3. Copy the CSV output or download it, then open it in Excel, Google Sheets, or Numbers.

Everything runs in your browser, so your data never leaves your device. Nothing is sent anywhere.

  • Going the other way? Use CSV to JSON to turn a spreadsheet back into structured data.
  • Need to inspect or fix messy JSON first? Try the JSON Formatter.
  • Want to sort and preview the result? Open it in the CSV Viewer.

Paste your JSON, copy the CSV, and your spreadsheet is ready.

← All posts