Skip to content
codevory

CSV to JSON Converter

Convert CSV to a JSON array of objects. Quoted fields, embedded line breaks and any delimiter are handled, and identifiers keep their leading zeros.

CSV to JSON Converter: the tool

Paste CSV to convert it to JSON.

Input

JSON

The result appears here.

How to use CSV to JSON

  1. Paste CSV into the left panel, or press Example. Data copied from a spreadsheet works as it is (tab-separated).
  2. The delimiter is detected automatically. Choose one yourself if the detection is wrong.
  3. Leave First row is the header on to get objects keyed by column name, or turn it off to get an array of arrays.
  4. Keep Detect numbers on to turn 98.5 into a number and true into a boolean, or turn it off to keep every value as text.

Example

A CSV with a quoted field that contains a comma and an empty cell, converted with the default options.

CSV
id,name,email,score,active
1,Ada Lovelace,ada@example.com,98.5,true
2,"Turing, Alan",alan@example.com,87,false
3,Grace Hopper,,92.25,true
JSON
[
  {
    "id": 1,
    "name": "Ada Lovelace",
    "email": "ada@example.com",
    "score": 98.5,
    "active": true
  },
  {
    "id": 2,
    "name": "Turing, Alan",
    "email": "alan@example.com",
    "score": 87,
    "active": false
  },
  {
    "id": 3,
    "name": "Grace Hopper",
    "email": null,
    "score": 92.25,
    "active": true
  }
]

About this tool

The parser follows RFC 4180. A field in double quotes can contain delimiters and line breaks, and a quote inside it is written twice. Errors such as an unclosed quote or a stray quote in an unquoted field are reported with their line and column instead of producing a wrong result. A leading byte order mark, which Excel adds, is ignored, and CRLF, LF and CR line endings are all accepted.

Type detection is cautious, because guessing wrong corrupts data. A value becomes a number only if it is a plain decimal with at most 15 significant digits and no leading zero, so 007, 01234 and a 20-digit identifier stay as text. true and false become booleans, and empty cells become null. Turn detection off to get strings only.

Rows with a different number of fields than the header are still converted: missing cells become null, extra cells are named column_N, and a warning points at the row. Duplicate column names are made unique (name, name_2). Blank lines are skipped.

Frequently asked questions

How does the converter decide what is a number?

Only plain decimals with at most 15 significant digits and no leading zero are converted. Postal codes, phone numbers, ids such as 007 and very long numbers stay as strings, so nothing is rounded or loses its zeros. Turn off type detection to keep every value as text.

My file uses semicolons. Will it work?

Yes. The delimiter is detected from the first lines, and it can be a comma, semicolon, tab or pipe. If the guess is wrong, select the delimiter yourself.

Can a field contain a line break?

Yes, if the field is wrapped in double quotes. The line break is kept inside the value, and line numbers in warnings still refer to the line where the record starts.

What happens if a row has the wrong number of columns?

The row is converted anyway and a warning gives its line. Missing cells become null and extra cells get the names column_N, so no data is dropped.

Can I convert an Excel file?

Not directly. Save the sheet as CSV first, or copy the cells and paste them here: copied spreadsheet cells are tab-separated, which the converter detects.