CSV to JSON

Convert CSV to JSON instantly in your browser.

Local Your input is processed locally in your browser. Found a problem? Report an issue

What CSV to JSON does

CSV to JSON reads CSV and writes it as JSON. The input is parsed first, so a syntax error is reported with its position instead of producing broken output.

CSV to JSON examples

The built-in sample

Input

id,name,city
1,Ada,London
2,Lin,Bengaluru

Output

[
  {
    "id": "1",
    "name": "Ada",
    "city": "London"
  },
  {
    "id": "2",
    "name": "Lin",
    "city": "Bengaluru"
  }
]

This is the input that the Load sample button fills in.

Quoted fields and a short row

Input

id,name,note
1,"Lovelace, Ada","said ""hi"""
2,Lin

Output

[
  {
    "id": "1",
    "name": "Lovelace, Ada",
    "note": "said \"hi\""
  },
  {
    "id": "2",
    "name": "Lin",
    "note": ""
  }
]

The comma inside "Lovelace, Ada" does not split the field, the doubled quotes become single quotes, and the second row, which has no third field, gets an empty note. Every value, including the ids, is a string.

Each output was produced by running this tool on the input above it.

How it works

Reading CSV. The first row is the header. Fields can be quoted to contain commas, line breaks and doubled quotes (""), following RFC 4180. Every following row becomes an object; all values are strings, and a row with fewer fields than the header is padded with empty strings.

Writing JSON. The result is written as JSON with two-space indentation.

Details and limits

  • There is no fixed size limit: everything runs on your device, so very large inputs depend on its memory.
  • It works in current browsers on phones, tablets and computers, and it is free with no account needed.
  • Values are carried across without losing anything in ordinary data; the points above list the cases the two formats handle differently.
  • Only the comma is a separator. A file exported with semicolons, as spreadsheets do in many European locales, ends up as a single column; replace the separator first.
  • If two columns have the same header, the right-hand one overwrites the other in each object.
  • Blank lines are skipped. A row longer than the header loses its extra fields.
  • A byte-order mark at the start of the file becomes part of the first header name. Remove it if the first key looks right but does not match in your code.

Common errors

Message or symptomWhat it means
Columns shift to the rightA value contains a comma but is not quoted. Quote it: "London, UK".
Missing valuesA row has fewer fields than the header; missing fields become empty strings.
A quote appears inside a valueInside a quoted field, write a double quote as two quotes: "".

Questions

How do I get numbers instead of strings?

CSV has no types, so every value is a string. Convert the fields you know to be numeric in your own code after parsing.