Disclosure: Some tools link to SaaS products we may earn a commission from — at no cost to you. All tools are free and run entirely in your browser. See full disclosure →
JSON
CSV
JSON Input 0 chars
CSV Output
Need the reverse? CSV to JSON Converter → JSON Formatter & Validator →

When you need JSON as CSV

The most common reason developers convert JSON to CSV is that someone downstream needs to open the data in Excel or Google Sheets. Data analysts, product managers, and finance teams live in spreadsheets. Giving them a JSON file is effectively giving them nothing — they can't open it without a developer's help. A CSV download button on your internal dashboard or data export feature is one of the highest-value QoL improvements you can ship.

The second common reason is pandas. The Python data science ecosystem assumes flat tabular data. pd.read_csv() is the most-used pandas entrypoint by a wide margin. Feeding pandas a raw JSON API response works (pd.read_json() exists), but normalising to CSV first lets you inspect the data in a spreadsheet before writing your analysis code.

Third: data pipelines. Many ETL and data-warehousing tools (dbt, Airbyte, Fivetran) have first-class CSV ingestion. If you're pulling data from a JSON API and loading it into a data warehouse, converting to CSV as an intermediate format simplifies the staging step significantly.

Column ordering and key extraction

This converter derives column headers from the keys of the first object in the array. That's a pragmatic choice — it's what most CSV conversion libraries do — but it has implications you should understand.

If later objects in the array have keys that the first object doesn't have, those extra keys will be silently ignored. Conversely, if a later object is missing a key that the first object has, that cell will be empty. This is intentional: CSV headers are fixed at the top of the file, so every row must conform to the same column list. If your JSON objects have varying shapes (they often do with NoSQL data), you have two options:

  • Derive headers from the union of all keys across all objects. This produces wider CSVs with more empty cells but doesn't lose any fields.
  • Normalise your JSON first to ensure every object has the same shape before converting.

Column order in the output follows JavaScript object key insertion order, which is deterministic in modern engines (V8, SpiderMonkey, JavaScriptCore) for string keys. If you need a different column order, reorder the keys in the first object before pasting — or sort them in the CSV output afterward.

Handling nested JSON before converting

The biggest gotcha with JSON-to-CSV conversion is nested objects. CSV can't represent nesting — it's strictly flat. If your JSON looks like this:

[{
  "name": "Alice",
  "address": {
    "city": "Vancouver",
    "country": "Canada"
  }
}]

The address field is an object, not a primitive — it can't be a CSV cell. You need to flatten it first. The standard approach is dot-notation flattening: address.city and address.country become separate columns.

In Python you can do this with pd.json_normalize(data) which handles dot-notation flattening automatically. In JavaScript, a two-line recursive flatten function gets you there. In jq: jq '[.[] | {name, city: .address.city, country: .address.country}]'.

Null, undefined, and empty strings in CSV

CSV has no native concept of null — it only has empty fields. This converter maps JSON null and missing keys to an empty string (,, in the CSV). That's the convention used by pandas, PostgreSQL's COPY, and most data warehouse CSV loaders.

However, this means you lose the distinction between "this field was explicitly null" and "this field was missing from the object." If that distinction matters for your use case (it often does in data engineering), you should pre-process your JSON to replace null with a sentinel string like \N (PostgreSQL's null marker) or NULL before converting.

Excel's CSV dialect vs RFC 4180

RFC 4180 is the closest thing CSV has to an official spec. It defines: comma delimiters, double-quote field quoting, "" for escaped double-quotes, and CRLF (\r\n) line endings. This converter produces RFC 4180-compliant output with LF (\n) line endings, which is the de facto standard for modern tooling.

Excel has its own CSV dialect quirks. On Windows, older Excel versions expect a BOM (byte order mark, U+FEFF) at the start of the file to correctly interpret UTF-8 encoding, otherwise non-ASCII characters get garbled. If you're exporting CSV for Windows Excel users with international data, prepend the UTF-8 BOM. Google Sheets and modern Excel on Mac/Windows 365 handle standard UTF-8 without the BOM correctly.

When CSV isn't enough

When your JSON data outgrows CSV — MongoDB Atlas stores it natively

Flattening nested JSON to CSV loses structure, and re-assembling it on the other end is tedious. MongoDB Atlas stores JSON documents natively with no schema migration required. Flexible indexing, full-text search, and aggregation pipelines — without the CSV shuffling. Free tier available, no credit card needed.

Try MongoDB Atlas Free →

Free tier: 512MB. No CC required.

Frequently Asked Questions

Why does my JSON have to be an array of objects?

CSV is a flat, tabular format — it has rows and columns but no nesting. An array of objects maps cleanly to that model: each object becomes a row, and the object keys become column headers. A single object or a deeply nested structure can't be represented as a flat CSV without first deciding how to flatten it, so this tool requires the flat array-of-objects shape. If your JSON is nested, flatten it first (tools like jq or a quick Python script can do this in seconds).

How does the converter handle commas and quotes inside values?

It follows RFC 4180 CSV escaping rules. If a field value contains a comma, a double-quote character, or a newline, the entire field is wrapped in double-quote characters. Any double-quote characters inside the value are doubled (escaped as ""). For example, the value She said "hello" becomes "She said ""hello""" in CSV. Most spreadsheet applications (Excel, Google Sheets, LibreOffice Calc) parse this correctly.

Will the converter preserve column order?

Column order is determined by the key order of the first object in the array. In modern JavaScript (V8, SpiderMonkey), object property insertion order is preserved for string keys that are not array indices. This means if your first object has keys in the order name, age, city, the CSV will have those columns in the same order. If you need a specific column order, reorder the keys in the first object before converting.

What happens to null or undefined values?

JSON null and missing keys output as empty fields in CSV — an empty string between the surrounding commas. This matches how pandas and most ETL tools expect missing data in CSV. If you need a specific null sentinel (like 'NULL' or 'N/A'), do a find-and-replace in the output after conversion.

Is this tool safe for sensitive data like API keys or PII?

Yes. The entire conversion runs in your browser using JavaScript. No data is transmitted to any server. You can verify this by opening your browser's DevTools Network tab — you will see zero outbound requests when you paste and convert. Your data never leaves your machine.

JSON & Data Tools
JSON Formatter JSON to YAML YAML to JSON CSV to JSON JSON to XML XML to JSON JSON Diff Text Diff JSON Tree Viewer
💡
Need AI tools for your development workflow?

Explore our reviews of the best AI coding assistants, documentation generators, and developer productivity tools — ranked by real-world usefulness.

Browse AI Tools for Developers →
The DevTools Team
Infinfy Engineering
We build free developer utilities that we actually use ourselves. No accounts, no tracking, no backend — just fast, accurate, in-browser tools. Part of Infinfy Solutions.