CSV to JSON Converter
Turns a CSV table into a JSON array of objects, guessing numbers and booleans.
Results
What this tool does
Going the other way from a spreadsheet: the first row becomes the field names and every row after it becomes an object. Values that look like numbers become numbers and true, false and null become JSON literals, because a table full of quoted "30" is rarely what anyone wanted. Quoted fields, embedded commas and doubled quotes are read the way RFC 4180 defines them, and semicolon or tab files work by changing the separator.
Formula
the first row gives the field names ; each following row becomes an object
Variables
| Symbol | Meaning | Unit |
|---|---|---|
text | CSV | — |
delimiter | Separator | — |
header | First row is the header | — |
indent | Spaces of indentation | — |
OUT | JSON | — |
RW | Rows | — |
CL | Columns | — |
Worked example
- CSVnome,idade,activo Ana,30,true Bruno,41,false
- Separator,
- First row is the header1
- Spaces of indentation2
- JSON[ { "nome": "Ana", "idade": 30, "activo": true }, { "nome": "Bruno", "idade": 41, "activo": false } ]
- Rows2
- Columns3
Limitations
- The calculation runs entirely in your browser. The values you type are never sent to a server.
Frequently asked questions
Why did my postcode lose its leading zero?
It did not — a value written as 0123 is not a valid JSON number, so it stays a string and keeps its zero. What does become a number is anything that looks like a proper one, and true, false and null become the JSON literals. That guessing is usually what you want and occasionally is not: a phone number written as 351912345678 will come out as a number. If every column must stay text, quote the values in the CSV.