How to Convert JSON to CSV (and Back) Without Losing Data Types
Converting between JSON and CSV is simple until nested objects and data types get involved. Here's what actually happens during the conversion.
Why this conversion isn't always lossless
JSON supports nested objects, arrays, and explicit types (numbers, booleans, null). CSV is flat β just rows and columns of text. Converting from one to the other means making decisions about how to flatten that structure.
What happens when you convert JSON to CSV
A typical JSON array of objects maps cleanly to CSV: each object becomes a row, each key becomes a column. The JSON to CSV tool handles this automatically. The cases that need attention:
- Nested objects β a field like
{"address": {"city": "Rome"}}doesn't have an obvious single CSV column. It either needs flattening (address.city) or gets serialized as a string. - Arrays inside objects β a
tags: ["a", "b"]field has no native CSV equivalent; it typically becomes a delimited string. - Missing keys β if some objects have a field and others don't, the CSV still needs a consistent column set, with empty cells for missing values.
What happens when you convert CSV to JSON
Going the other way, CSV to JSON has the opposite challenge: CSV has no type information. "42" could be a number or a string; "true" could be a boolean or just text. A good converter uses dynamic typing to infer the right type from the value itself, so numbers come back as numbers and not quoted strings.
A practical tip
If you're round-tripping data (JSON β CSV β JSON), check the result with the JSON Formatter afterward β it makes it immediately obvious if a number got turned into a string or a nested field got flattened in a way you didn't expect.
Convert your file now β entirely in your browser, nothing uploaded.