CSV and JSON: the details that break a conversion
Delimiters, quotes, leading zeros, BOMs and dates: the parts of a CSV file that silently change when it becomes JSON, and how to check the result before anyone imports it.
2026-12-01
The delimiter is the first thing to verify
A CSV exported from Excel in Germany, France or Italy usually separates columns with semicolons, because the comma is already the decimal separator. A file from a US or UK setup uses commas. Tab-separated exports from older systems look identical in a text editor and fail in the same way.
If the preview shows one very wide column, the delimiter is wrong. Do not edit the file to fix it; choose the right character and look again. One reliable check is to count separators on the first line: a header with five fields should contain four delimiters, no more and no less.
Quotes and line breaks inside a cell
The CSV rules allow a field to be wrapped in double quotes so it can contain the delimiter, a line break or a quote itself. A quote inside a quoted field is written twice. This is why an address like 12 Rue de l'Église, Apt 3 can survive in one cell while the file still uses commas.
Broken quoting is the most common reason a conversion produces garbage. One unclosed quote at the end of a long row swallows everything after it into a single cell. If a converter reports an unterminated quote, look at the line above the error first; that is usually where the missing quote is.
Leading zeros, long IDs and ambiguous dates
If a converter turns 01234 into 1234, it has decided the value is a number. Postcodes, product codes and phone numbers are identifiers, not quantities, and they need to stay as text. The same applies to 19-digit IDs that exceed JavaScript's safe integer range and come back rounded.
Dates are worse because the file does not say what 03/04/2025 means. It is March 4 in one country and April 3 in another, and guessing wrong shifts a report by a month. Keep the original string and parse it with the locale you know the export came from, not with the locale of the person reading the result.
The invisible BOM and the wrong encoding
Excel likes to start a UTF-8 file with a byte order mark. It is invisible in most editors but becomes part of the first header, so a column appears to be called id while code that compares it to id fails. Stripping the BOM before parsing is one line of work that prevents an afternoon of debugging.
Older exports may not be UTF-8 at all. A file saved as Windows-1252 shows accents as mojibake, and no JSON conversion can repair that automatically. Open it in an editor that lets you choose the encoding, save as UTF-8, then convert. The damage from re-saving the wrong way round is permanent.
JSON is not automatically a better table
JSON is the right target when the data has to go into an API, a config file or a test fixture. It is the wrong target when the data is genuinely rectangular and stays rectangular: a spreadsheet is easier to scan, sort and print than a nested array. Use the conversion for transport, not as an upgrade.
Two structural problems show up in most real exports. Duplicate header names would silently overwrite each other in a JSON object, so they need a suffix. Ragged rows with too many or too few cells usually mean a broken quote or delimiter upstream, and padding them hides the real error. Check those rows before you trust the output.