Skip to content

JSON to CSV Converter

Convert a JSON array of objects to CSV and back, in your browser. Flattens nested keys and escapes fields per RFC 4180.

Runs entirely in your browser. Nothing you paste here is sent to us or anyone else โ€” there is no server processing, no logging of input, and no third-party scripts on this page.

This tool converts a JSON array of objects into CSV โ€” and CSV back into JSON โ€” right in your browser. Pick a direction, paste your data on the left, and get the result on the right. JSON to CSV derives the full column set, flattens nested objects into dot-notation columns, and quotes fields exactly as RFC 4180 requires. CSV to JSON parses quoted fields, embedded commas, and multi-line cells into clean objects. Nothing you paste is transmitted anywhere.

What are JSON and CSV?

JSON (JavaScript Object Notation) is a nested, typed data format used by nearly every web API and config file. CSV (Comma-Separated Values) is a flat, tabular text format understood by spreadsheets, databases, and data-analysis tools. Moving between them is one of the most common chores in day-to-day data work: an API hands you JSON, but a colleague wants a spreadsheet; or a spreadsheet export needs to become the JSON payload for an import.

How JSON becomes CSV

The converter expects a JSON array where every element is an object, for example:

[
  {"id": 1, "name": "Ada", "contact": {"city": "London"}},
  {"id": 2, "name": "Grace", "contact": {"city": "New York"}}
]

Each object becomes one row. To build the header, the tool scans every object and collects the union of all keys in first-seen order, so even if some rows have extra fields, no column is lost. Rows missing a key simply get an empty cell.

Nested objects are flattened with dot notation: {"contact":{"city":"London"}} becomes a column called contact.city. Nested arrays flatten by index, so a tags array turns into tags.0, tags.1, and so on. This guarantees a genuinely flat, rectangular table that any spreadsheet can open.

Correct escaping (RFC 4180)

Naive CSV generation breaks the moment a value contains a comma, a quote, or a line break. This tool follows the RFC 4180 rules precisely:

Field contains How it is written
a comma the whole field is wrapped in double quotes
a double quote each quote is doubled, and the field is wrapped in quotes
a newline the field is wrapped in quotes and the newline is preserved
none of the above written as-is, unquoted

For example, the value Alan, "The" Turing is written as "Alan, ""The"" Turing". The CSV-to-JSON parser reverses each of these rules exactly, so a value with an embedded comma or newline survives a full round trip unchanged.

How CSV becomes JSON

The first row is treated as the header, and each following row becomes an object keyed by those headers. The parser is a real state machine, not a naive split on commas, so it correctly handles quoted fields that contain commas, doubled quotes, and even line breaks inside a single cell. Both Windows (CRLF) and Unix (LF) line endings are accepted, which covers exports from Excel, Google Sheets, and most databases.

Because CSV has no concept of types, the Typed values option decides what to do with cells that look like numbers or booleans. With it on, 42, true, false, and null become their real JSON types; with it off, everything stays a string. Numeric strings with leading zeros such as 007 are always kept as text so identifiers are never silently mangled.

Common use cases

  • Turning an API response into a spreadsheet a non-developer can open.
  • Preparing CSV for a bulk import that expects JSON.
  • Flattening nested API data into columns for quick analysis or a pivot table.
  • Sanity-checking that a CSV export parses cleanly before loading it into a database.

Runs entirely in your browser

The whole conversion happens on your device with plain JavaScript โ€” there is no server round-trip, no logging, and no third-party analytics on this page. That makes it safe for internal exports and data you would rather not upload. For the most sensitive files you can load the page once and then work offline. Use the Sample button to see a representative input for whichever direction you have selected, and Download to save the result as a .csv or .json file.

Frequently asked questions

Is my data sent to a server?

No. The conversion runs entirely in your browser using vanilla JavaScript. Nothing you paste is uploaded, logged, or stored, so you can even disconnect from the internet and it still works.

What JSON shape does it expect?

An array of objects, like [{"id":1,"name":"Ada"},{"id":2,"name":"Grace"}]. Each object becomes one CSV row. A single object is accepted too and is treated as a one-row array. Arrays of primitives or mixed non-object elements are rejected because they have no columns.

How are nested objects handled?

They are flattened with dot-notation keys. An object like {"contact":{"city":"London"}} produces a column named contact.city. Nested arrays are flattened by index, so tags[0] becomes tags.0. This keeps every value in a flat, tabular column.

How are commas, quotes and newlines escaped?

Following RFC 4180: any field containing a comma, double quote, or line break is wrapped in double quotes, and any double quote inside it is doubled. On the way back, the parser reverses this exactly, so values with embedded commas or newlines survive a round trip.

What is the "Typed values" option in CSV to JSON?

CSV has no types โ€” every cell is text. With Typed values on, cells that look like numbers, true, false, or null are converted to real JSON types. With it off, every value stays a string. Numeric-looking strings with leading zeros such as 007 are always kept as strings to avoid data loss.

What happens if rows have different keys?

The converter builds the union of all keys across every object, in first-seen order. Rows that are missing a given key get an empty cell for that column, so no data is dropped and the table stays rectangular.

Does the column order stay stable?

Yes. Columns appear in the order keys are first encountered while scanning the array top to bottom. This makes the output deterministic and easy to diff.

Can it handle CSV exported from Excel or Google Sheets?

Yes. The parser accepts both CRLF and LF line endings, quoted fields, embedded commas, doubled quotes, and multi-line quoted cells, which covers the CSV that spreadsheets and most databases produce.