How to Turn CSV into JSON
By Tools Star Hub Editorial Team · Published
The first row becomes the keys. Each following row becomes an object. Quoted cells can contain commas. A doubled quote inside a quoted cell becomes one quote. An empty cell becomes an empty string. An unclosed quote is rejected.
A spreadsheet and a JSON array use different rules for commas and quotes. Converting in the page lets you check the keys and the empty cells before you use the file.
How to convert CSV to JSON
- Paste the CSV, including the header row. The header becomes the object keys, in that order.
- Convert. The page reads the text in the browser.
- Check empty cells. A trailing comma with nothing after it is an empty string, not a missing key.
- Fix an unclosed quote before you retry. The page rejects the CSV instead of guessing where the cell ends.
Example
A quoted comma and an empty cell
The rows name,note then "Doe, Jane","say ""hi""" then Sara, become JSON with Doe, Jane, the note say "hi", and a second object whose note is an empty string.
FAQ
- Why is the comma inside the name one field?
- The name is wrapped in quotes, so the comma is part of the cell.
- How is a quote inside a cell written?
- CSV doubles it. A pair of quotes inside quotes becomes one quote in the JSON string.
- What is an empty cell?
- An empty string. It is not null, and it is not a dropped key.
- What if a quote is never closed?
- The conversion is rejected.
To turn a header row and data rows into a JSON array, use CSV to JSON.