Getting Spreadsheet Data into Code Without Pain
By toolbelt maintainers ·
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?
Why did my numbers become strings?
Can it handle quoted commas?
What about duplicate headers?
Related tools
- JSON to CSVConvert a JSON array into a clean CSV file. Extract unique keys to form the header row, perfect for exporting API data for analysis in Excel or Google Sheets.
- XML to JSONConvert XML documents to JSON objects. Bridge the gap between legacy SOAP APIs and modern frontend applications while preserving attributes and hierarchical data.
- JSON to XMLConvert JSON objects to valid XML markup. Automatically handle arrays, attributes, and special characters, making it easy to integrate with older enterprise systems.
- YAML to JSONConvert YAML configuration into JSON, or JSON back into clean YAML. Parse errors report the line and column so you can fix the file quickly.