How to Convert CSV to JSON Correctly
Converting CSV to JSON sounds trivial — split on commas, zip with the header — and that naive approach breaks on the first quoted field. Here is what a correct conversion has to handle.
What a proper conversion does
- 1Detect the delimiter: comma, semicolon, tab or pipe
- 2Parse quoted fields, including embedded commas, newlines and doubled quotes
- 3Use the first row as keys, or generate keys when there is no header
- 4Decide types: numbers, booleans and null, or keep everything as strings
- 5Handle empty cells consistently — empty string, null or omitted key
- 6Emit an array of objects, one per data row
A worked example
id;name;note;active
1;Ada;"Wrote the first algorithm, in 1843";true
2;Grace;"Said: ""ship it""";false[
{
"id": 1,
"name": "Ada",
"note": "Wrote the first algorithm, in 1843",
"active": true
},
{
"id": 2,
"name": "Grace",
"note": "Said: \"ship it\"",
"active": false
}
]Note the semicolon delimiter, the comma living safely inside a quoted field, and the doubled quotes collapsing to a single escaped quote in JSON.
Type inference: useful and dangerous
| Cell | Inferred | Risk |
|---|---|---|
| 42 | number 42 | None |
| 007 | number 7 | Leading zeros lost — keep as string |
| +441234567890 | number or string | Phone numbers must stay strings |
| true | boolean | Usually correct |
| empty string or null | Pick one and document it | |
| 2026-06-02 | string | JSON has no date type |
| 1.234,56 | string | Locale decimal comma — normalise first |
When a column holds identifiers — SKUs, postcodes, phone numbers, account numbers — turn inference off for it. Losing a leading zero is silent and painful.
Converting in the browser
Convert a CSV file to JSON
- 1
Open the converter
Open TheToolSera CSV to JSON. Parsing happens locally in your tab.
- 2
Add the CSV
Paste the text or drop the file in.
- 3
Check the delimiter and header
Confirm the detected delimiter and whether the first row contains column names.
- 4
Choose type handling
Enable inference for numeric data, or keep values as strings for identifier columns.
- 5
Review the output
Scan the first few objects for shifted columns — the classic sign of a quoting problem.
- 6
Copy or download
Take the JSON array, or format it further if it feeds a config file.
CSV to JSON
Convert CSV to JSON with delimiter detection and type handling — nothing is uploaded.
Producing nested JSON
If your CSV uses dotted headers such as address.city and address.postcode, an expanding converter can rebuild nesting from them. Without that convention the output is necessarily flat — which is usually fine, and can be reshaped afterwards.
id,address.city,address.postcode
1,London,NW1 6XE
-> { "id": 1, "address": { "city": "London", "postcode": "NW1 6XE" } }Common mistakes
Splitting on commas
Quoted fields legally contain commas and newlines. A naive split shifts every subsequent column.
Ignoring the BOM
A UTF-8 byte-order mark attaches itself to the first header, producing a key like "\ufeffid" that never matches.
Trusting the header row blindly
Duplicate or empty header cells silently overwrite keys. Deduplicate before converting.
Converting huge files in one pass
For very large exports, stream to NDJSON — one object per line — rather than building a single array.
Frequently asked questions
How do I keep leading zeros when converting CSV to JSON?
Disable numeric type inference for that column so the value stays a string. Converting 007 to a number permanently loses the zeros.
What if my CSV uses semicolons?
A good converter detects the delimiter automatically, and lets you override it if detection is ambiguous.
Can CSV to JSON produce nested objects?
Only if the headers encode nesting, typically with dotted names like address.city. Otherwise the output is flat.
Is converting CSV online safe?
It is when the parsing runs in your browser. TheToolSera converts locally, so business data never leaves your device.
Put this into practice
CSV to JSON runs entirely in your browser — no upload, no account, no limits.
Open CSV to JSONRelated tools
Related guides
CSV vs JSON: Choosing the Right Data Format
Compare CSV and JSON on structure, nesting, file size, streaming, typing and tooling, with clear guidance on which to use for exports, APIs and analytics pipelines.
What Is JSON? A Plain-English Guide
JSON explained without jargon: what it is, how the syntax works, which data types it supports, where it is used and how it differs from JavaScript objects.
How to Format JSON (Beautify, Indent and Minify)
Learn how JSON formatting works, see a before-and-after example, fix the errors that block beautifying, and format JSON online in your browser without uploading a file.
JSON vs XML: Which Format Should You Use?
A practical JSON vs XML comparison: syntax, size, parsing speed, schemas, comments, attributes and metadata — plus clear guidance on which format fits which job.
Why Client-Side Tools Are Safer for Your Files
What actually happens when you upload a file to an online converter, how browser-based processing differs, how to verify a tool's claims, and when a server is unavoidable.
How to Format SQL for Readable, Reviewable Queries
A practical SQL formatting guide: keyword casing, indentation, join and CTE layout, comma placement, and how consistent formatting makes reviews and debugging faster.