Ctrl K

How to Convert CSV to JSON Correctly

beginner TheToolSera Team 6 min read Updated 5 Jun 2026

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

  1. 1Detect the delimiter: comma, semicolon, tab or pipe
  2. 2Parse quoted fields, including embedded commas, newlines and doubled quotes
  3. 3Use the first row as keys, or generate keys when there is no header
  4. 4Decide types: numbers, booleans and null, or keep everything as strings
  5. 5Handle empty cells consistently — empty string, null or omitted key
  6. 6Emit an array of objects, one per data row

A worked example

CSV with a quoted field
id;name;note;active
1;Ada;"Wrote the first algorithm, in 1843";true
2;Grace;"Said: ""ship it""";false
JSON output
[
  {
    "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

CellInferredRisk
42number 42None
007number 7Leading zeros lost — keep as string
+441234567890number or stringPhone numbers must stay strings
truebooleanUsually correct
empty string or nullPick one and document it
2026-06-02stringJSON has no date type
1.234,56stringLocale 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. 1

    Open the converter

    Open TheToolSera CSV to JSON. Parsing happens locally in your tab.

  2. 2

    Add the CSV

    Paste the text or drop the file in.

  3. 3

    Check the delimiter and header

    Confirm the detected delimiter and whether the first row contains column names.

  4. 4

    Choose type handling

    Enable inference for numeric data, or keep values as strings for identifier columns.

  5. 5

    Review the output

    Scan the first few objects for shifted columns — the classic sign of a quoting problem.

  6. 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.

Try CSV to JSON

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 JSON

Related tools

Related guides

All guides

Explore related topics