Uvlio

Command Palette

Search for a command to run...

Back to articles
Technical Article

JSON and CSV Are Not Equivalent: What Gets Lost During Conversion

JSON and CSV often meet at the boundary between APIs and spreadsheets. It is tempting to think conversion is mechanical: objects become rows, keys become headers, and values fill cells. That works for simple data, but the formats were built for different shapes. JSON can represent nested objects and arrays. CSV represents rows of text fields. Every conversion makes decisions, and those decisions should be visible.
Uvlio editorial team by limitcool2026-05-177 min read
Topic coverDeveloperJSONCSV

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.

Guide subject preview
{"name":"Ava","role":"admin"}
name,email,role
validate rows before import
Tool stack
JSON ⇄ CSV ConverterJSON Formatter
Reading focus
1Inspect shape
2Map fields
3Validate rows

Original workflow visual

JSON and CSV Are Not Equivalent: What Gets Lost During Conversion

This original Uvlio visual summarizes the practical path from input inspection to output review for this workflow.
1

Inspect shape

Review before moving forward

2

Map fields

Review before moving forward

3

Validate rows

Review before moving forward

Maintainer and review note
Maintained by limitcool. Use it to understand the technical model, processing boundaries, privacy risks, and verifiable behavior.
CSV is a table of text fields

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 can represent deeper structure

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.

Headers become a contract

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.

Null, empty string, and missing field are not the same

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.

Spreadsheets reinterpret data

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.

Quoting and newlines deserve tests

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.

A safer conversion workflow

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

Can every JSON file become one CSV file?

No. Deeply nested JSON often needs flattening rules, multiple tables, or a deliberate loss of detail.

Why did my ID lose leading zeros in a spreadsheet?

The spreadsheet probably interpreted it as a number. The raw CSV may still contain the original text.

What is the safest test sample?

Use a small sample with commas, quotes, empty values, non-ASCII text, nested fields, and at least one value that must not change.

How should nested arrays be represented in CSV?

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.

Why do dates change after opening CSV?

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.