Going from a spreadsheet to code usually means CSV to JSON. The header row becomes the keys, every following row becomes an object. The details that trip people up are quoting rules and values that are numbers in the sheet but strings in the JSON.
What you'll learn
- Parse RFC 4180 style CSV including quoted commas and newlines
- Map the header row to object keys
- Decide how to treat numbers, empty cells and duplicate headers
Step by step
-
Paste the CSV with its header row
Open CSV to JSON and paste the text. The first row must be the header; everything after it is data.
-
Click Convert
Each row becomes an object keyed by the header. Values are strings; convert types in your code if you need numbers.
id,name 1,Ada 2,"Grace, Hopper" → [ { "id": "1", "name": "Ada" }, { "id": "2", "name": "Grace, Hopper" } ] -
Check for a header-only file
If only a header was found you get an empty array and a note saying so. Add data rows and convert again.
-
Copy the JSON
Copy Output and drop it into your code or a fixture file.
Common problems
Values are strings, not numbers
CSV has no types, so everything is text. Convert in your code, or post-process with a small script if you need numbers and booleans.
Rows have too few values
Missing trailing cells become empty strings. Check the source export for rows that were truncated.
FAQ
What about semicolon-separated files?
Replace the semicolons with commas first, taking care with quoted fields, or export the sheet again as comma-separated.