Formatters

Convert CSV rows to JSON objects

CSV to JSON converter parses the CSV you paste following RFC 4180: the first row becomes the object keys, each following row becomes one JSON object, and quoted fields can contain commas, doubled quotes and line breaks. The delimiter is detected from the first line (comma, semicolon, tab or pipe) and can be set by hand, and values stay strings exactly as written, so 007 is not turned into 7. Untick "First row is the header" to get an array of arrays instead.

How to use CSV to JSON

  1. Open CSV to JSON in the Toolbox101 app.
  2. Paste the CSV into the CSV box, header row first.
  3. Leave Delimiter on Detect, or choose comma, semicolon, tab or pipe if detection guesses wrong.
  4. Read the array of objects in the Output box. Untick First row is the header if the file has no header.
  5. Click Copy to take the JSON.

Worked example

CSV to JSON returns the output below for this input.

Input

name,role,city
Ada Lovelace,Engineer,London
Alan Turing,Researcher,Manchester

Output

[
    {
        "name": "Ada Lovelace",
        "role": "Engineer",
        "city": "London"
    },
    {
        "name": "Alan Turing",
        "role": "Researcher",
        "city": "Manchester"
    }
]

Check it yourself: open CSV to JSON and enter the same input.

Frequently asked questions

What if a CSV field contains a comma or quotes?

It works as the CSV format says: wrap the field in double quotes, and write a literal quote as two. "Smith, John" is one cell, and a quoted field can even span several lines. An opening quote that is never closed is reported as an error.

What happens to empty cells and short rows?

An empty cell becomes an empty string, such as "city": "", and a row with fewer cells than the header is padded with empty strings. A row with more cells than the header gets extra keys named column_4 and so on. Blank lines are skipped.

What if my CSV has no header row?

Untick First row is the header and the output is an array of arrays, one per row, instead of objects. With the box ticked the first row supplies the keys: repeated names get a _2, _3 suffix, and an empty name becomes column.

Are numbers and booleans converted?

No. Every value stays a string, exactly as it appears in the CSV, because a CSV cell carries no type: 007, 1e3 and true are all kept as written. Convert them in your own code, where you know which columns are numeric.

Use CSV to JSON now

Runs in your browser. Nothing you type is uploaded.