Skip to main content
CuteJSON
↑↓ Navigate Enter Select Esc Close

How to convert JSON to CSV without losing data

Published 2 min read By Akash Kinkar Pandey

CSV has no specification everyone follows, which is exactly why so many converters disagree with each other on edge cases. This tool follows RFC 4180 and states the one place it departs from it, rather than picking rules quietly.

Using the JSON to CSV converter

Choose a direction, set the delimiter (comma, semicolon or tab) and whether the first row holds column names, then press Convert. Going to CSV needs an array of objects, the only JSON shape that is genuinely a table; a single object is accepted too, taken as a table of one row.

Converting

[{"name":"Doe, Jane","age":30,"note":null},{"name":"Smith","age":25,"note":"line1\nline2"}]

produces:

name,age,note
"Doe, Jane",30,
Smith,25,"line1
line2"

A field is quoted only when it actually needs it: the comma inside “Doe, Jane” forces quotes, the embedded line break in the second note forces quotes, and a plain value like Smith is left bare.

What happens to nested values and null

A nested object or array has no CSV form at all, a grid of single values, so it is written into the cell as its own JSON text rather than dropped or spread into invented columns. null becomes an empty field, which does mean a null and an empty string are indistinguishable once they reach CSV. Both choices are stated on the page rather than discovered later.

Why every field comes back a string

Converting from CSV, every value stays a string, deliberately. A CSV file records no types at all, so guessing them is how a postcode of 01234 loses its leading zero and becomes 1234, and how a long identifier gets rounded the moment something tries to read it as a number. Converting the columns you know about into numbers afterward is one line of code; a silently rounded identifier is not recoverable. Reading back the example above, age returns as the string "30", not the number 30, and the empty note field returns as "", not null.

Swap direction

Swap moves the current output into the input and flips the direction, so you can immediately check that a document round trips through CSV and back the way you expect, without retyping anything. Try it on data with a comma inside a field or a leading zero in an ID, since those are exactly the cases most converters get wrong.

Back to all posts