How to Convert JSON to CSV (and Back)

Pageonaut · June 27, 2026

How to Convert JSON to CSV (and Back)

JSON and CSV are two of the most common ways to move structured data around, and you constantly need to cross between them. An API hands you JSON; your colleague wants a spreadsheet. A client emails a CSV export; your script expects JSON. The two formats describe data very differently, so the conversion is rarely a one-line job. This guide explains how they map to each other, how to handle the messy parts like nested data and stray commas, and how to convert in both directions without losing anything.

Why convert between JSON and CSV at all

The two formats serve different worlds. CSV is the language of spreadsheets — flat tables of rows and columns that Excel, Google Sheets and almost every database import tool understand natively. It is compact, human-readable and perfect for tabular data like records, exports and reports.

JSON is the language of APIs and code. It carries hierarchy: objects inside objects, lists inside fields, mixed types. Web services speak it, configuration files use it, and most programming languages parse it in a single call.

You convert between them because your data needs to live in both worlds. You pull JSON from an API and need it in a spreadsheet for a non-technical colleague to filter and chart. Or you receive a CSV export and need JSON to feed it into code, a database or another API. Each format is the right tool for one job and the wrong tool for the other.

How the structures map

The cleanest mental model: a JSON array of objects is a CSV table. Each object becomes a row, and each key becomes a column header.

Take this JSON:

[
  { "name": "Ada", "role": "Engineer", "active": true },
  { "name": "Linus", "role": "Maintainer", "active": false }
]

That maps directly to:

name,role,active
Ada,Engineer,true
Linus,Maintainer,false

The first row holds the column names, gathered from the keys. Every following row holds one object's values in the same column order. As long as your JSON is a flat list of similar objects, the conversion is almost mechanical — which is exactly the shape most API responses and database queries return.

Handling nested objects and arrays

Real JSON is rarely flat, and this is where conversion gets interesting. CSV has no concept of nesting — every cell is a single value — so deeper structures have to be flattened into columns.

The common approach is dot notation for nested objects. A value like:

{ "name": "Ada", "address": { "city": "Berlin", "zip": "10115" } }

becomes two columns, address.city and address.zip, rather than one impossible "address" cell. Arrays are trickier. A list of tags might become indexed columns (tags.0, tags.1) or get joined into a single cell with a separator like Berlin; Munich. Neither is perfect: indexed columns explode when lists are long, and joined cells need a delimiter your data never contains.

A good converter makes these choices for you and stays consistent, so the same nested shape always lands in the same columns. When data is deeply nested, it is sometimes cleaner to reshape the JSON first — flattening or selecting the fields you actually need before converting.

Gotchas: commas, quotes, encoding and missing keys

CSV looks simple but hides sharp edges, and most broken conversions trace back to one of these:

  • Commas inside values. A field like Berlin, Germany contains the very character that separates columns. The fix is quoting: wrap the value in double quotes so "Berlin, Germany" stays one cell.
  • Quotes inside values. If a value already contains a double quote, it must be escaped by doubling it — She said "hi" becomes "She said ""hi""". Skipping this corrupts every column after it.
  • Line breaks inside values. Multi-line text in a single cell is legal only when the value is quoted; otherwise the row splits in two.
  • Encoding. Names with accents or non-Latin scripts need UTF-8. Open a UTF-8 file as something else and José turns into mojibake. Save and read as UTF-8 throughout.
  • Missing or extra keys. Not every object carries the same fields. A solid converter collects the union of all keys for the header and leaves cells empty where a key is absent, instead of shifting columns out of alignment.

Get these right and your CSV survives the round trip; get them wrong and the file looks fine until one bad row breaks the whole import.

Going back: from CSV to JSON

The reverse direction reads the header row as keys and turns every following row into an object. The table above rebuilds into the original array of objects, one per row.

Two things deserve care. First, types. CSV stores everything as text, so true, 42 and 2026-06-27 all arrive as strings. Depending on your needs you may want numbers and booleans parsed back into real JSON types rather than left as quoted text. Second, structure. If your CSV used dot-notation headers like address.city, a good converter can rebuild the nested objects rather than leaving you with a flat record full of dotted keys. Reversing the flattening cleanly is what makes a true round trip possible.

Convert in your browser, privately

You don't need to paste sensitive data into a random website to reshape it. Conversion is pure data transformation that modern browsers handle locally, with no server involved.

Our free JSON ↔ CSV Converter runs entirely in your browser — paste JSON to get CSV, or paste CSV to get JSON, and download the result. It is free, needs no sign-up, and because everything runs on your machine your data never leaves your computer, which matters when you are handling exports, customer records or anything confidential. If your JSON is messy or invalid before you start, clean it up with the JSON Formatter first so the conversion has valid input to work from. You can find more developer tools for the rest of your workflow.

FAQ

Can any JSON be converted to CSV?

Not always cleanly. A flat array of objects maps perfectly to rows and columns. Deeply nested objects and arrays have to be flattened — usually with dot-notation columns or joined cells — which works but can produce wide or awkward tables. If your JSON is a single object or irregularly shaped, reshape it into a list of similar records first.

What happens to data types when I convert?

CSV has no types; every value is stored as plain text. Going from JSON to CSV, numbers and booleans become text. Going back from CSV to JSON, a good converter can re-parse obvious numbers and booleans into real JSON types, but you should confirm the result matches what you expect, especially for values like ZIP codes that look numeric but should stay strings.

Is it safe to convert confidential data online?

With Pageonaut, yes. The JSON ↔ CSV Converter runs entirely in your browser, so nothing is uploaded to a server. Your data stays on your own machine throughout the conversion, which makes it safe for customer exports, internal records and other sensitive files.

Try the tool

JSON ↔ CSV Converter

Open JSON ↔ CSV Converter