JSON and CSV Are Not Equivalent: What Gets Lost During Conversion
JSON and CSV Are Not Equivalent: What Gets Lost During Conversion
A practical technical article on converting between JSON and CSV, including nesting, headers, quoting, nulls, types, and spreadsheet assumptions.
Original workflow visual
JSON and CSV Are Not Equivalent: What Gets Lost During Conversion
Inspect shape
Review before moving forward
Map fields
Review before moving forward
Validate rows
Review before moving forward
CSV has rows and columns. Each cell is text, even if a spreadsheet later displays it as a number, date, or formula. Delimiters, quotes, newlines, and escaping rules define how text is separated. This is a good fit for flat records such as contacts, transactions, inventory items, or report rows. It is a poor native fit for nested structures unless you first choose a flattening strategy.
JSON objects can contain arrays, objects, booleans, null values, and numbers. A single order can contain customer details, shipping address, line items, discounts, and metadata. Flattening that into CSV requires choices: repeat order fields for each line item, join arrays into one cell, create multiple CSV files, or drop details. None of those choices is automatically correct. The destination system decides which mapping is useful.
When CSV becomes JSON, headers often become object keys. That makes header spelling, capitalization, spaces, and duplicate names important. "User ID", "user_id", and "userid" may be treated as different fields. When JSON becomes CSV, key order becomes column order, and missing keys become empty cells. Before exporting, choose stable headers and document whether they are intended for humans, a spreadsheet, or an import system.
JSON can distinguish null from an empty string and from a missing field. CSV usually shows all of them as some form of empty cell unless you define conventions. This matters for imports. An empty cell might mean "leave unchanged," "clear the value," or "unknown." If the conversion will update records, decide how each empty state should be represented before the file reaches the destination system.
Opening CSV in a spreadsheet can change how values appear. Long numbers may be displayed in scientific notation, leading zeros may disappear, dates may be parsed according to local settings, and cells beginning with certain characters may be treated as formulas. A CSV converter may have produced correct text, but the spreadsheet can still alter the display. For IDs, postal codes, phone numbers, and money values, inspect the raw CSV as text before blaming the converter.
A realistic CSV sample should include a comma inside a field, a quote character, a blank value, and a newline inside a quoted cell if the destination allows it. Those examples reveal whether the parser and writer agree about escaping. Clean demos that contain only simple names and numbers do not prove much. Conversion should be tested against the messy punctuation that real exported data often contains.
Start by inspecting the source shape. If JSON is nested, decide whether to flatten, split, or summarize. If CSV is going to JSON, confirm headers and empty value rules. Convert a small sample first, then compare row count, key count, data types, and a few edge cases. For production imports, add schema validation after conversion. The goal is not merely to produce a file; it is to preserve the meaning the destination expects.
Common Questions
No. Deeply nested JSON often needs flattening rules, multiple tables, or a deliberate loss of detail.
The spreadsheet probably interpreted it as a number. The raw CSV may still contain the original text.
Use a small sample with commas, quotes, empty values, non-ASCII text, nested fields, and at least one value that must not change.
There is no universal answer. You can create one row per child item, join values into a delimited cell, create separate CSV files, or keep the nested field as JSON text inside one cell. The correct choice depends on the import system and whether the relationship between parent and child records must remain queryable.
Spreadsheet software may guess date formats according to local settings. A value such as 01/02/2026 can mean different dates in different regions. For imports, prefer explicit formats such as ISO-style dates and inspect the raw CSV text before trusting the spreadsheet display.