Skip to main content

Convert CSV to JSON

Each CSV row becomes one JSON object, and the header row supplies the property names. This guide runs a small file with a quoted comma and an escaped quote through the converter and explains every rule it applies.

Worked example

Input (CSV)
id,name,item,price,paid
1,"Smith, Jane","Monitor 27""",189.99,true
2,Kim,Keyboard,,false
Output (JSON)
[
  {
    "id": 1,
    "name": "Smith, Jane",
    "item": "Monitor 27\"",
    "price": 189.99,
    "paid": true
  },
  {
    "id": 2,
    "name": "Kim",
    "item": "Keyboard",
    "price": null,
    "paid": false
  }
]

Because "Smith, Jane" is wrapped in double quotes, its comma stays inside the value instead of starting a new column. In "Monitor 27""" the doubled quote becomes one literal quote mark. Kim's empty price becomes null, and numbers and true/false come out as JSON types, not strings.

How the converter handles it

  • Every non-blank line is one record and blank lines are skipped. A quoted value cannot contain a line break.
  • Wrap a value in double quotes when it contains the delimiter. Inside quotes, write a quote mark as two quotes ("").
  • Spaces at the start and end of each value are removed.
  • With “First row as headers” on, the first line provides the keys; with it off, the keys are col0, col1, col2 and so on.
  • Empty cells and the word null become null, true and false (any capitalization) become booleans, and numeric text becomes a number even when quoted, so 00123 becomes 123.
  • Rows with fewer values than headers get null for the missing columns; values beyond the last header are dropped.

More conversion guides