JSON that converts cleanly
The easiest shape is an array of objects with consistent keys. In [{"name":"Baro","score":95}], each object becomes a row and keys become columns.
Different keys create blank cells. Normalize required keys and value types where possible before conversion.
CSV headers and quoting
The first CSV row normally contains column names. A value containing a comma, quote, or line break must be quoted, and quotes inside the value are doubled.
Splitting text on every comma will break addresses and sentences, so use a parser that follows CSV quoting rules.
- First row: column names
- Comma or line break: quote the value
- Quote inside a value: double it
Nested objects and arrays
One CSV cell cannot directly represent hierarchy. Preserve an object or array as a JSON string in one cell, or flatten only the fields you need.
If the CSV must become JSON again, document which columns are numbers, booleans, or nested JSON. CSV values may otherwise return as strings.
Checks before opening in a spreadsheet
Spreadsheets may remove leading zeros from postal or product codes and convert long numbers to scientific notation.
Do not upload sensitive source data without confirming local processing. After conversion, compare row count, header count, and representative samples with the original.