Start with the shape of the data

JSON represents objects, arrays, strings, numbers, booleans and null. CSV is a table of fields and records; it does not provide the same built-in type system. Use CSV when a consistent row-and-column layout is the goal. Keep JSON when records contain nested objects or variable-length lists. A clean-looking table is not proof that every original relationship survived.

Keep identifiers as text

A code such as 00127 is an identifier, not necessarily the number 127. Store it as text and import its spreadsheet column as text. The same caution applies to telephone numbers and very large numeric IDs. Ordinary JavaScript numbers cannot represent every integer beyond 9,007,199,254,740,991 exactly. If precision matters, use quoted strings or a tool that explicitly supports the required numeric range.

Let a parser handle CSV

A comma inside a quoted field is data, not a column boundary. A quoted field can also contain a line break, and embedded double quotes need escaping. Splitting each line on commas is therefore insufficient. Before conversion, check the delimiter, header row, duplicate column names and whether all records have the expected number of fields. Do not silently discard rows that fail validation.

Decide how nested values should map

An order with several items needs an explicit export rule. You might use a separate item table with an order ID, or preserve the list as JSON text in one cell. Flattening objects can create confusing names when keys already contain the chosen separator. Record the mapping and use the same rule on reimport. Formatting and sorting object keys should not be confused with reordering an array.

Check a small round trip first

Convert a representative sample, import it again and compare record counts and selected values. Include accents, empty strings, null values, quotes and multiline text. When opening untrusted CSV in a spreadsheet, inspect cells that may be interpreted as formulas and use the application’s text-import controls. Keep the source file and your conversion settings. These checks catch meaning changes that a successful download message cannot detect.

Editorial research based on the sources listed below.

www.rfc-editor.org · developer.mozilla.org