Converting a CSV file to JSON looks like a one-line job, until the output has the wrong types or the rows shift. These are the five problems I see most often, and how to check for each one.
1. Every value becomes a string
A CSV has no types. The number 42 and the text "42" are the same thing in the file. A converter has to guess, and the guess can be wrong, especially for IDs like 007 or phone numbers that start with a zero. If you convert 007 to the number 7, the data is damaged. Decide per column whether it is a number, a string or a boolean, and keep IDs as strings.
2. Commas inside values
A value such as "Delhi, India" must be wrapped in double quotes in the CSV. Without the quotes the row gets an extra column and everything after it shifts. If a quote appears inside a quoted value, it is written twice.
id,city,note 1,"Delhi, India","She said ""hello""" 3. The wrong delimiter
Some tools and regions export with a semicolon or a tab instead of a comma. If your whole row lands in one field, check the first line of the file in a plain text editor before you debug anything else.
4. Empty cells
An empty cell can become an empty string, null, or a missing key. They mean different things to the code that reads the JSON, so pick one rule and apply it to every column.
5. Encoding and the BOM
A CSV saved by Excel as UTF-8 often starts with an invisible byte order mark. It can end up glued to the first header name, so the key becomes a strange string instead of "id". Strip it before you parse.
const text = raw.replace(/^\uFEFF/, ""); A quick checklist
- Open the file in a text editor and look at the first five lines.
- Confirm the delimiter and the encoding.
- Convert a small sample first and compare the types.
- Validate the final JSON before you use it.
Disclosure: I work on SnipFerry, a set of free browser-based JSON, CSV and SQL tools (https://snipferry.com). It runs in your browser, so you can also paste a sample there to check the result. The checks above apply to any converter you use.