How to Convert CSV to JSON
CSV (Comma-Separated Values) is the simplest format for tabular data — every spreadsheet can export it. JSON (JavaScript Object Notation) is the standard format for web APIs and modern applications. Converting between them is one of the most common data tasks in development.
When you need CSV to JSON
- Loading data into a web application — most JavaScript frameworks work with JSON natively, not CSV
- API payloads — if you have data in a spreadsheet that needs to go to an API endpoint, it needs to be JSON
- Database imports — many NoSQL databases (MongoDB, Firebase) accept JSON directly
- Configuration files — turning a spreadsheet of settings into a JSON config file
- Data analysis — converting exported data into a format your tools can process
How CSV becomes JSON
A CSV file:
name,age,city
Alice,30,New York
Bob,25,London
Becomes a JSON array of objects:
[
{"name": "Alice", "age": "30", "city": "New York"},
{"name": "Bob", "age": "25", "city": "London"}
]
The first row (headers) becomes the keys. Each subsequent row becomes an object.
How to convert
- Paste your CSV data — enter comma-separated data with a header row.
- Choose your delimiter — select comma, semicolon, tab, or pipe. The tool auto-detects in most cases.
- Copy or download — review the JSON output and copy it to your clipboard or download as a
.jsonfile.
Handling tricky CSV data
Quoted values — when a value contains the delimiter character (like an address with a comma), it should be wrapped in double quotes: "New York, NY". Good converters handle this correctly.
Empty values — empty cells become empty strings in JSON ("field": ""). If you need them as null, you may need to post-process the output.
Numeric values — CSV does not have data types. Everything is text. The JSON output will have numbers as strings ("30" not 30). If your application needs actual numbers, parse them after conversion.
Line breaks in values — some CSV files have multi-line values (enclosed in quotes). Not all converters handle this — test with your specific data.
Tips
- Check your headers — the first row must be clean, unique column names. Spaces, special characters, or duplicate headers will create messy JSON keys.
- Verify the delimiter — European CSVs often use semicolons instead of commas (because commas are used as decimal separators in many European countries). If conversion looks wrong, try a different delimiter.
- Format the output — after conversion, run the JSON through a formatter to make it readable before using it in your project.
- Spot-check the results — compare a few rows of the JSON output against the original CSV to make sure the mapping is correct, especially for files with many columns.
Frequently Asked Questions
What happens to the header row?
The first row is used as keys for the JSON objects. Each subsequent row becomes an object with those keys. For example, a header of "name,age" with a row of "Alice,30" becomes {"name":"Alice","age":"30"}.
What delimiters are supported?
Comma, semicolon, tab, and pipe delimiters are all supported. The tool can auto-detect which delimiter your data uses, or you can select it manually.
Does it handle commas inside values?
Yes. Values enclosed in double quotes (like "New York, NY") are handled correctly — the comma inside the quotes is treated as part of the value, not a separator.
Is my data sent to a server?
No. All conversion happens in your browser. Your data never leaves your device.