DeveloperMar 13, 2026 ยท Updated Oct 13, 2026 ยท 3 min read

How to Convert JSON to CSV (and CSV to JSON)

Convert JSON to CSV and back without losing data. We fed awkward values to pandas, Papa Parse and Python's csv module: ZIP codes lost their leading zeros and a 16-digit order ID came back with the wrong last digit.

๐Ÿ”„
Try the JSON-CSV Converter
Free, no signup
โ†’
DG
Derek Giordano
Designer & Developer
In this guide
01JSON to CSV02CSV to JSON03Measured: What Readers Do to Awkward Values04Quoting Rules (RFC 4180)05In Code

JSON to CSV

A flat array of objects maps directly: each object is a row, each key a column.

[{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]

name,age
Alice,30
Bob,25

Nested data has to be flattened. The usual convention, and the one the JSON-CSV Converter uses, is dot notation: {"user": {"name": "Alice"}} becomes a user.name column, and array items become tags.0, tags.1. Keys missing from some objects become empty cells, which is why a JSON โ†’ CSV โ†’ JSON round trip brings absent keys back as empty strings: CSV cannot tell "missing" from "empty".

CSV to JSON

Each row becomes an object keyed by the header row. CSV has no types, so everything arrives as text; the risk is in what a converter does to that text when it guesses types.

Measured: What Readers Do to Awkward Values

We fed one small CSV with a ZIP code, phone numbers, long order IDs, a price, booleans and dates to three common readers (October 13, 2026; file and script in our test folder):

Value in the CSVpandas 3.0.2 read_csv, defaultsPapa Parse 5.4.1, dynamicTypingPython csv module
ZIP 0213421342134"02134"
Order ID 90071992547409939007199254740992.0 (wrong last digit)"9007199254740993" (kept as text)"9007199254740993"
Order ID 123456789012345678901.2345678901234567e+19kept as textkept as text
1e31000.01000"1e3"
Price 1.101.11.1"1.10"
TRUE"TRUE"true"TRUE"

Every reader handled the quoted comma, the doubled quotes and the line break inside a quoted field correctly; the damage is all in type guessing. ZIP codes and phone numbers lose leading zeros, and integers above 253 (9,007,199,254,740,992) cannot survive as JavaScript or float64 numbers: even JSON.parse("9007199254740993") returns 9007199254740992. Treat identifiers, codes and anything with a leading zero as text, and only convert columns you know are numeric.

The JSON-CSV Converter converts a value to a number only when it is a canonical JSON number within 253, so 02134, 0x1A and 20-digit IDs stay text, and true/false conversion is optional. We checked it against Python's csv module on 12 awkward files when we rebuilt it.

Quoting Rules (RFC 4180)

In Code

JavaScript: Papa.parse(text, { header: true }) and Papa.unparse(rows); leave dynamicTyping off, or limit it to known numeric columns with its per-column function form. Python: csv.DictReader keeps everything as text; with pandas pass dtype=str (or a per-column mapping) to read_csv to stop it rewriting IDs.

Frequently Asked Questions

How do I convert JSON to CSV?+
Flatten nested objects into dot-notation headers (user.name), give array items indexed columns (tags.0, tags.1), and write one row per object, quoting any field that contains a comma, quote or line break. The JSON-CSV Converter does this in your browser.
How do I convert CSV to JSON?+
Treat the first row as headers and each following row as an object, following RFC 4180 quoting. Keep values as text unless a column is known to be numeric: type guessing turns ZIP 02134 into 2134 and corrupts IDs above 2^53 (pandas returned 9007199254740992 for 9007199254740993 in our test).
How do I handle nested JSON in CSV?+
Nested objects are typically flattened with dot notation (user.name, user.email). Arrays can be joined with a delimiter or expanded into multiple rows depending on your use case.
Try it yourself

Use the JSON-CSV Converter โ€” free, no signup required.

โšก Open JSON-CSV Converter
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.