Skip to content
toolbelt
Back to Guides

Getting Spreadsheet Data into Code Without Pain

By ·

Updated

Someone sends you a spreadsheet. You need it as JSON. This is the boring problem with more edge cases than you expect.

What is this tool?

CSV to JSON reads the header row as keys and each following row as an object. Simple in principle, fiddly in practice.

How it works

The file is parsed properly, which means quoted fields containing commas work, and so do embedded newlines inside quotes. Then each row is paired with its header. Values stay strings unless the whole column is unambiguously numeric.

Example

name,age,active
Ada,36,true
Grace,45,false

becomes
[
  { "name": "Ada", "age": 36, "active": true },
  { "name": "Grace", "age": 45, "active": false }
]

When to use it

Importing a customer list. Turning a spreadsheet of test data into fixtures. Migrating data out of a tool that only exports Excel.

Optimization Tips

Check your type inference before trusting it. A column of IDs like 007 will lose its leading zeros the moment it becomes a number. If that matters, treat the column as a string.

Frequently Asked Questions

What if my CSV uses semicolons?
That is common in Europe. The parser handles it, but confirm the delimiter before assuming the output is wrong.
Why did my numbers become strings?
Mixed or empty cells in a column keep it a string, which is safer than silently changing data.
Can it handle quoted commas?
Yes. A field like "Smith, John" stays one value.
What about duplicate headers?
Later duplicates overwrite earlier ones in the resulting object. Rename the columns first.

Ready to try it out?

Put this knowledge into practice with our free tool.

Go to Tool

Related tools