JSON to CSV Converter — Free Online Tool

Paste JSON, get a CSV file — handles arrays, nested objects, and missing keys instantly

Last reviewed:

Rows: 0
Columns: 0
Preview (first 5 rows)

What Is JSON to CSV Conversion?

JSON to CSV conversion transforms structured API or application data into a flat spreadsheet format. If you’ve ever pulled data from a web API, exported records from a database, or worked with a JavaScript application’s data layer, you’ve likely encountered JSON — and needed it in a spreadsheet.

The conversion is conceptually simple but full of edge cases: missing keys, nested objects, special characters in values, and arrays within arrays all require careful handling. This tool manages all of those automatically, producing a valid CSV you can open directly in Excel, Google Sheets, or import into any database.

How the Conversion Works

Input: A valid JSON value — typically an array of objects.

Output: A CSV file where the first row is the header (all unique keys found across all objects) and each subsequent row is one object from the array.

The conversion follows three rules:

Rule 1 — Header generation: The converter scans every object in the array and collects the union of all keys. If 999 objects have a name field and one doesn’t, name still appears as a column — the missing object gets an empty cell. No keys are silently dropped.

Rule 2 — Value serialization: Strings are written as-is. Numbers and booleans are converted to their string representation. null and undefined become empty cells. Nested objects and arrays are serialized as compact JSON text within the cell — you see {"city":"Austin","state":"TX"} as the cell value rather than a blank or an error.

Rule 3 — RFC 4180 escaping: Any cell containing a comma, double quote, or newline is wrapped in double quotes. Double quotes within a value are escaped by doubling (" becomes ""). This is the standard CSV escaping rule and ensures compatibility with Excel, Google Sheets, pandas, and every SQL database import tool.

A Worked Example

Say your API returns this JSON:

[
  {"id": 1, "name": "Alice", "city": "Austin", "score": 94.5},
  {"id": 2, "name": "Bob", "score": 87},
  {"id": 3, "name": "Carol, PhD", "city": "Denver", "score": null}
]

Three edge cases here: Bob has no city key, Carol’s name contains a comma, and Carol’s score is null.

The converter produces:

id,name,city,score
1,Alice,Austin,94.5
2,Bob,,87
3,"Carol, PhD",Denver,

Bob’s city cell is empty. Carol’s name is quoted because it contains a comma. Carol’s score is an empty cell because null maps to nothing. The header row includes city even though Bob’s record doesn’t have it. This is the correct behavior per RFC 4180 and what every major data tool expects.

Common Use Cases

API Response Processing

Most REST APIs return JSON. If you’re analyzing API data in Excel or Google Sheets — user records, product catalogs, transaction logs, survey results — you need CSV. Paste the API response directly into this tool, click Convert, and download the file.

For large responses, use your browser’s developer tools (F12 → Network tab) to copy the response body, then paste here. The converter handles arrays of any size that fit in browser memory — typically tens of thousands of rows.

Database Exports

Many databases (MongoDB, Firebase, Postgres with JSON columns) can export to JSON. This tool converts those exports to CSV for import into another database, a data warehouse, or analysis in R or Python. The union-of-keys approach is particularly useful for MongoDB documents, which often have inconsistent schemas across records.

Spreadsheet Imports

Google Sheets and Excel both support CSV import directly. After converting, download the .csv file and use File → Import in Google Sheets or Data → From Text/CSV in Excel. The result is a properly formatted spreadsheet with column headers from your JSON keys.

Data Cleaning Pipelines

In a typical data pipeline: fetch JSON from API → convert to CSV → load into pandas or Excel → clean and analyze. This tool handles step two. For automated pipelines, consider Python’s json and csv standard library modules, which implement the same logic programmatically.

Working with Nested JSON

Nested objects (a field whose value is itself an object) are a common challenge. This converter serializes them as compact JSON text in the cell. For example, an address object {"street": "123 Main", "city": "Austin"} becomes the string {"street":"123 Main","city":"Austin"} in one cell.

If you need those nested fields as separate columns, you’ll need to flatten the JSON first — either manually restructure it before pasting, or use a tool like jq in the command line:

jq '[.[] | {id, name, street: .address.street, city: .address.city}]' input.json

Then paste the flattened output here. This two-step approach gives you full control over which nested fields become columns.

Handling Large Files

Browser-based conversion works well up to a few megabytes of JSON. For files larger than ~10 MB, consider command-line tools: Python’s standard library handles arbitrarily large files without loading everything into memory, and jq is extremely fast for JSON processing on Unix systems.

Key Assumptions and Limitations

This converter assumes your JSON is a valid array of objects — the most common format returned by APIs and database exports. Single objects are supported (output as key-value pairs). Flat arrays produce a single-column CSV. Deeply nested structures (objects containing arrays containing objects) are not automatically flattened — nested values appear as JSON strings in the cell. For files that are too large for the browser, use Python’s csv and json modules, which stream data without loading it all into memory. The download uses UTF-8 encoding, which is compatible with Google Sheets, modern Excel, and all major data tools.

Frequently Asked Questions

What JSON formats does this converter support?

The converter handles three formats: an array of objects (most common — each object becomes a row), a single object (converted to two columns: key and value), and a flat array of values (converted to a single-column CSV). Nested objects within array items are stringified as JSON text in the cell unless they contain only one level of nesting, in which case they can be optionally flattened.

How does the converter handle missing keys across objects?

When objects in your array have different keys — for example, one record has an 'email' field and another doesn't — the converter collects the union of all keys from all objects and uses that as the header row. Objects missing a key get an empty cell in that column. No data is dropped.

Does this tool handle special characters in CSV?

Yes. Any cell value containing a comma, double quote, or newline is automatically wrapped in double quotes per RFC 4180. Double quotes within values are escaped by doubling them (""). This ensures the CSV opens correctly in Excel, Google Sheets, and any standards-compliant parser.

Is my JSON data sent to a server?

No. The conversion runs entirely in your browser using JavaScript. Your data never leaves your device and is not stored, logged, or transmitted anywhere.

What is the difference between JSON and CSV?

JSON (JavaScript Object Notation) is a hierarchical format that supports nested structures, arrays, and mixed data types — ideal for APIs and application data. CSV (Comma-Separated Values) is a flat tabular format with rows and columns — ideal for spreadsheets, databases, and data analysis tools. Most data analysis workflows require CSV because tools like Excel, R, pandas, and SQL imports expect tabular input.

Can I convert CSV back to JSON?

This tool converts JSON to CSV only. To convert CSV back to JSON, you can use a spreadsheet (Google Sheets has a built-in CSV import), or tools like csvjson.com. Most workflows run in one direction: APIs return JSON, analysts need CSV.