JSON to CSV Converter

Convert an array of JSON objects into a CSV file with automatic header detection, nested object flattening, and proper quoting of special characters. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-18

Overview

Introduction

Spreadsheets and JSON speak different languages: one's rows and columns, the other's nested key-value structures. This converter bridges the two, turning an array of JSON objects into a proper CSV file you can open straight in Excel, Google Sheets, or Numbers.

That translation isn't always mechanical. JSON objects can nest arbitrarily deep, and different objects in the same array can carry different keys, neither has a direct CSV equivalent. This tool makes the same structural calls a developer would make by hand: flattening nesting into dot-notation columns, merging inconsistent keys into one header row, so you're not reshaping the data yourself before it's usable in a spreadsheet.

What Is JSON to CSV Converter?

A JSON-to-CSV converter maps each object in a JSON array to one CSV row, using the union of every object's keys as column headers, and quotes values correctly when they contain commas, quotes, or line breaks.

It also handles a single JSON object (a one-row CSV) or a flat array of primitives (wrapped into a single 'value' column). The output is a standards-compliant CSV file, not just comma-joined text, so it opens cleanly in spreadsheet software with no manual fixing needed.

Conversion runs entirely client-side. Both the CSV text and the downloadable file get produced locally in the browser, and nothing about the data you convert is sent anywhere. The output follows RFC 4180's quoting rules precisely, though it joins rows with a plain newline instead of the RFC's specified CRLF, a difference every mainstream spreadsheet application tolerates without issue.

How JSON to CSV Converter Works

The tool parses the JSON, flattens nested objects into dot-notation column names (e.g. address.city), collects every distinct key across all rows to build a stable header row, and serializes nested arrays as JSON strings inside a single cell. Values get quoted per RFC 4180 whenever they contain the delimiter, a quote character, or a newline.

Column order follows first-seen order across the array, not alphabetical sorting. If the first object has keys id, name, email, those become the first three columns even if a later object introduces something new like role. That keeps the layout predictable and close to your source JSON's shape instead of shuffling columns based on a sort nobody asked for.

A few input shapes get special treatment. An empty array produces an empty output string rather than a header-only CSV. A bare object (not wrapped in an array) produces a single data row. And an array of arrays has no keys to use as column names, so each inner array gets serialized whole into one 'value' column instead of being expanded positionally.

When To Use JSON to CSV Converter

Use it when you've got API output, a database export, or a log file in JSON form and need to hand it to someone who lives in spreadsheets, or when you need to import the data into a tool that only takes CSV.

It also comes up mid-pipeline, turning a JSON fixture into CSV to feed a data-import step, or converting a JSON log export so it can be filtered and pivoted in a spreadsheet instead of grepped by hand.

Features

Advantages

  • Automatically detects and merges columns across objects with inconsistent keys.
  • Flattens nested objects into readable dot-notation columns instead of dropping the data.
  • Produces RFC 4180-compliant quoting, so values with commas or quotes don't break the file.
  • Works entirely offline, which matters when the data contains sensitive records.

Limitations

  • Deeply nested arrays get serialized as JSON strings rather than expanded into further rows or columns.
  • Very wide objects (hundreds of distinct keys) can produce unwieldy CSVs; spreadsheets just aren't built for deep hierarchies.
  • CSV has no native types, so numbers, booleans, and strings all become plain text in the output.

CSV vs. JSON: When to Use Each

CSV vs. JSON: When to Use Each
CSVJSON
Natural fit forFlat, tabular data (rows and columns)Nested, hierarchical data
Opens directly inExcel, Google Sheets, NumbersCode editors, API tools
Preserves data typesNo, everything is textYes, strings, numbers, booleans, null
Best forSharing data with non-technical teammatesAPIs, configs, and structured data

Examples

Array of user objects

Input

[{"id":1,"name":"Ada"},{"id":2,"name":"Grace"}]

Output

id,name
1,Ada
2,Grace

Each object becomes a row, and the union of keys across both objects becomes the header row.

Flattening a nested object into dot-notation columns

Input

[{"id":1,"user":{"name":"Ada","address":{"city":"London"}}}]

Output

id,user.name,user.address.city
1,Ada,London

Nesting collapses fully into the column name no matter how deep it goes, a value two levels down (address.city inside user) becomes a single flat column, user.address.city.

Nested array serialized as a single JSON-string cell

Input

[{"id":1,"tags":["admin","editor"]}]

Output

id,tags
1,"[""admin"",""editor""]"

The tags array gets written as the literal text ["admin","editor"] inside one cell, quoted because that JSON text itself contains commas and double quotes, both of which trigger RFC 4180's quoting rules.

Escaping a value with a comma and embedded quotes

Input

[{"id":1,"note":"Hello, \"world\""}]

Output

id,note
1,"Hello, ""world"""

The note value contains both a comma and double quotes, so the whole cell gets wrapped in quotes and each internal quote is doubled, exactly as RFC 4180 specifies, and the file still parses correctly.

Merging objects with inconsistent keys

Input

[{"id":1,"name":"Ada"},{"id":2,"role":"editor"}]

Output

id,name,role
1,Ada,
2,,editor

The header row is the union of every key seen across the array, in first-seen order. The first row has no role, the second has no name, so each just gets a blank cell instead of the row being dropped or misaligned.

An array of arrays collapses to a single column

Input

[[1,2],[3,4]]

Output

value
"[1,2]"
"[3,4]"

This isn't a flat array of objects, so there are no keys to use as column names. Each inner array gets treated as a single value and serialized whole into one 'value' column instead of being expanded into separate columns per position. Want one column per position instead? Convert each inner array to an object with named keys, like {"x":1,"y":2}, before converting.

Best Practices & Notes

Best Practices

  • Flatten deeply nested structures in your source data before converting if you need one meaningful column per field.
  • Double-check columns holding arrays, they show up as raw JSON text and often need manual splitting downstream.
  • Use a consistent object shape across your array for the cleanest CSV output.
  • Got an array of arrays instead of an array of objects? Convert it to named-key objects first, or every row collapses into a single opaque 'value' column instead of one column per position.
  • Don't read a blank cell as false or zero. Only null and a missing key produce an empty cell, real false and 0 values get written out as text, so treat blanks as 'absent or null,' not as a falsy value.
  • If the destination system insists on strict RFC 4180 line endings (CRLF), post-process the downloaded file. This converter joins rows with a plain newline, which nearly all modern tools accept even though the RFC technically specifies CRLF.

Developer Notes

Column order follows first-seen order across the array, not alphabetical order, so the CSV layout stays predictable and close to your source JSON's key order. The first object encountered establishes the initial columns, and later objects only ever append new columns at the end, they never reorder existing ones. Flattening recurses through nested objects to any depth using dot-notation keys, but treats arrays as opaque leaves, JSON.stringify()'d into a single cell rather than recursed into, since there's no natural column mapping for a variable-length list. Quoting follows RFC 4180 (double-quote wrapping with doubled internal quotes) whenever a cell contains the active delimiter, a double quote, or a newline. Line endings between rows are a plain \n rather than the RFC's specified \r\n though, a deliberate simplification since virtually every real-world CSV consumer accepts bare LF just fine.

JSON to CSV Converter Use Cases

  • Exporting API results for a non-technical teammate to open in Excel
  • Preparing JSON log data for spreadsheet-based analysis
  • Converting a JSON fixture into CSV for a data import tool
  • Sharing a quick tabular view of structured JSON data
  • Producing a spreadsheet-ready export from a JSON API response for a stakeholder who doesn't want to touch raw JSON
  • Feeding flattened JSON records into a tool or import wizard that only accepts delimited text, like a CRM or a legacy database loader

Common Mistakes

  • Pasting a single deeply nested object and expecting multiple rows, only array elements become rows.
  • Expecting nested arrays to expand into columns instead of landing in a single JSON string cell.
  • Forgetting that CSV column order can shift if object key order varies between array items.
  • Passing an array of arrays instead of an array of objects and expecting one column per position. Without object keys to name the columns, each inner array collapses into a single JSON-string cell instead.
  • Reading a blank cell as false or 0. A blank cell actually means the key was missing or explicitly null, real false and 0 values always show up as visible text.
  • Assuming the output uses CRLF line endings because RFC 4180 specifies them. This converter uses a plain LF, which is fine for virtually every modern CSV consumer but can matter for strict legacy parsers.

Tips

  • If your data has inconsistent keys, review the header row carefully, missing values just show up as blank cells.
  • For deeply nested data, consider flattening manually before converting so the columns match your reporting needs.
  • Switch the delimiter to semicolon before sharing a CSV with a European-locale spreadsheet, where comma is often the decimal separator and Excel expects semicolon-delimited files by default.
  • Scan the header row for one-off column names after converting a large array. A single object with an unusual extra key adds a column that's blank for every other row, which is often a sign of a malformed or outlier record worth investigating.

References

Frequently Asked Questions