Conversion
How to Convert JSON to CSV Without Losing Data
Plan a JSON-to-CSV export that handles nested objects, arrays, nulls, identifiers, quoting, and spreadsheet formulas with clear tradeoffs.
CSV is a table, while JSON can describe a hierarchy. Decide what each row means and how values map to columns before exporting.
Define one row before you click Convert
Converting JSON to CSV is a modeling decision before it is a formatting task. A JSON order might contain a customer object, several items, and a delivery address. Should the spreadsheet contain one row per order, one row per item, or a separate sheet for each collection? Those choices produce different totals and different column meanings.
JSONSlate’s JSON-to-CSV tool expects an array of objects. For a one-row-per-customer export, the following fixture is a reasonable starting point. If your source is wrapped in a data property, extract the records first. If you need one row per nested item, reshape the records deliberately before conversion; do not assume flattening creates that business view.
[
{
"id": "0042",
"customer": {"name": "Ada, Lin"},
"tags": ["priority", "newsletter"],
"note": null
},
{
"id": "0043",
"customer": {"name": "Sam"},
"tags": []
}
]Choose a nesting and array policy
The converter flattens nested fields to escaped paths by default, producing columns such as customer.name. That helps you see a nested value in a spreadsheet, but the column name is now part of an export mapping. Keep that mapping if another program needs to reconstruct the source.
Arrays need particular care. A list of tags can become indexed columns when flattened, while unflattened nested values are exported as JSON text. Neither approach automatically creates one row per tag. Indexed columns may also grow wider when later records contain longer arrays.
Decide which representation the receiver can use. For a monthly report, a dedicated tag-count column may be more useful than the entire list. For a migration, preserving the source JSON alongside the CSV may be essential. Preview records with empty arrays and unusually long arrays before treating the export as complete.
Keep null, missing values, and identifiers intentional
In the fixture, the first customer has an explicit null note; the second has no note property. JSONSlate exports null as the text null by default and a missing value as a blank cell. An empty string can also appear blank. A receiver cannot reliably infer the original distinction from appearance alone.
If the distinction matters, include an explicit presence column or agree on a documented sentinel. A literal string "null" can collide with a null marker, so no marker is automatically lossless. CSV does not carry the full JSON type system; treat any reverse import as a new interpretation.
The identifier "0042" needs similar attention. A spreadsheet may infer a number and drop its leading zeros. Import the identifier column as text using the spreadsheet’s import controls, then inspect the value. Merely placing a CSV field in quotes does not reliably prevent a spreadsheet from inferring its type.
Let a CSV writer handle quotes, then check spreadsheet behavior
Do not build CSV by joining values with commas. Fields containing commas, quotes, or line breaks need CSV quoting and escaping. RFC 4180 describes the common convention of quoting such fields and doubling internal double quotes. That is why Ada, Lin must remain a single field rather than becoming two columns.
A separate issue appears when a spreadsheet interprets a cell as a formula. JSONSlate enables apostrophe-prefix formula escaping by default through its CSV writer. This changes affected exported cells and is a precaution, not a guarantee for every spreadsheet. OWASP notes that spreadsheet behavior and save/reopen cycles can defeat common escaping strategies.
For untrusted input, review the target spreadsheet’s import options and keep fields as text where possible. Test the actual application and workflow the recipient uses. A machine-oriented CSV consumer may need the exact original text instead, which is another reason to document the export policy.
References: RFC 4180: common CSV quoting rules · OWASP: CSV injection and mitigation limitations
Verify the file in the receiving application
After converting, open a representative sample through the receiver’s import flow. Count the rows and columns, check identifiers and non-ASCII names, and compare a few totals against the original records. Do not judge success only by how the preview looks in the browser.
- Confirm one output row represents the intended entity.
- Inspect commas, quotes, embedded newlines, and Unicode.
- Check nulls, missing fields, empty strings, false, and zero.
- Verify leading-zero identifiers and formula-like text.
- Retain the original JSON and the mapping used for export.
Put it into practice
Explore the examples in your own browser. Core JSON processing stays on your device.
Continue learning: JSON-to-CSV quick guide.

