Developer

How to Convert JSON to CSV: Quoting and Nested Data

ToolOrbit Engineering 2 min readUpdated
How to Convert JSON to CSV: Quoting and Nested Data

JSON is the format APIs speak; CSV is the format spreadsheets and analysts speak. Moving between them sounds trivial until a value contains a comma, a quote, or a line break and your file falls apart. The ToolOrbit JSON to CSV Converter handles the conversion in both directions with proper quoting and escaping so your data survives the trip.

How the conversion works

To turn JSON into CSV, the converter takes an array of objects, collects the keys to form the header row, and writes each object as a row of values. Going the other way, it reads the header row to name the fields and produces an array of objects. The hard part is not the layout but the escaping.

[{"name":"Ada","role":"Engineer, Lead"},
 {"name":"Bo","role":"Designer"}]
->
name,role
Ada,"Engineer, Lead"
Bo,Designer

Why correct quoting matters

  • A value containing a comma must be wrapped in double quotes so it stays one field
  • A double quote inside a value is escaped by doubling it
  • Values with newlines must be quoted so the row is not split in two
  • Consistent headers keep columns aligned even when some objects miss a key
Tip: When opening CSV in Excel, watch out for values like leading zeros or long numbers being reformatted. If preserving exact text matters, import as text rather than double-clicking the file.

Using the converter

Paste a JSON array to get CSV, or paste CSV to get a JSON array back. The tool follows the standard quoting rules so files open cleanly in Excel, Google Sheets, and data-processing scripts alike. Conversion runs entirely in your browser, so even confidential exports stay on your machine.

Best practices

Make sure your JSON is a flat array of objects for the cleanest CSV; deeply nested structures do not map onto a grid without flattening first. Keep field names consistent across records, use UTF-8 to preserve accented characters, and always quote on output if there is any chance a value contains a delimiter.

Flattening nested data without losing it

CSV is a flat grid; JSON nests freely. The safe conversion path flattens nested objects into dotted columns (profile.name becomes a profile.name column) while arrays need a different treatment — usually one row per array element with the parent fields repeated. “Flatten objects / repeat rows for arrays” is the option set that matches how spreadsheets actually consume data. Wherever a value contains commas, quotes or newlines, the quotes do the protecting; that is why the converter always quotes conservatively.

Row count is your sanity check: JSON with 10 objects should produce 10 CSV rows (or N×array-length rows), never zero and never one giant blob.

Tools mentioned

More reading

View all guides
What Is Base64? How Encoding Works and Common Mistakes
Developer

What Is Base64? How Encoding Works and Common Mistakes

What Base64 encoding actually does, where it is used, and the mistakes that cause broken or oversized output.

2 min readUpdated
encodeURI vs encodeURIComponent: Which One to Use
Developer

encodeURI vs encodeURIComponent: Which One to Use

How percent-encoding works, the difference between encoding a whole URL and a single component, and the mistakes that break links.

2 min readUpdated
What Is a UUID? Version 4 vs Version 7 Explained
Developer

What Is a UUID? Version 4 vs Version 7 Explained

What a UUID looks like, why version 4 is the safe default, when version 7 is better, and best practices for IDs.

2 min readUpdated
How SHA-256 and SHA-512 Hashes Work: Hashing vs Encryption
Developer

How SHA-256 and SHA-512 Hashes Work: Hashing vs Encryption

What a hash function does, how to choose between SHA-256 and SHA-512, and why hashing is not encryption.

2 min readUpdated
What Is a JWT? Header, Payload and Signature Explained
Developer

What Is a JWT? Header, Payload and Signature Explained

A JSON Web Token has three parts. Learn what the header, payload and signature contain, how to read the claims, and why decoding is not verifying.

2 min readUpdated
What Is HTML Encoding? Entities & Escaping Explained
Developer

What Is HTML Encoding? Entities & Escaping Explained

Learn how HTML encoding works, why escaping prevents XSS and layout breaks, and how to encode and decode named, decimal, and hex entities.

2 min readUpdated
Unix Time Explained: Seconds, Milliseconds and Time Zones
Developer

Unix Time Explained: Seconds, Milliseconds and Time Zones

What a Unix timestamp is, how to tell seconds from milliseconds, how time zones come into it, and the values worth recognising.

2 min readUpdated
Binary, Octal, Decimal and Hex: How Number Bases Work
Developer

Binary, Octal, Decimal and Hex: How Number Bases Work

How positional number bases work, why very large values need exact arithmetic, and the hex and binary values you meet every day.

2 min readUpdated