DevSwitch.net
Back to Tools
⇄

CSV to JSON Converter

Convert CSV data to JSON format

File Converters

Tip: Paste your CSV data with comma-separated values. The first row will be used as object keys in the JSON output.

Runs in your browser

Input CSV

Convert CSV to JSON in your browser

Paste CSV, open a .csv file or drop it on the input window, and the JSON appears as you type. Each row becomes one object in a JSON array, with the column names from the first row as its keys. Copy the result or download it as a .json file.

The CSV is read by the rules of RFC 4180, the format spreadsheets export: a field in double quotes can hold commas, line breaks and doubled quotes, so an address like "Portland, OR" stays one value instead of splitting into two columns.

CSV to JSON example

Real output for a two-row export. The quoted city keeps its comma, and the ZIP code with a leading zero stays text:

customers.csv
id,name,city,zip,active
1,Mara Quill,"Portland, OR",97201,true
2,Theo Brandt,Boston,02134,false
customers.json
[
  {
    "id": 1,
    "name": "Mara Quill",
    "city": "Portland, OR",
    "zip": 97201,
    "active": "true"
  },
  {
    "id": 2,
    "name": "Theo Brandt",
    "city": "Boston",
    "zip": "02134",
    "active": "false"
  }
]

How CSV values become JSON

CSV has no types, every cell is text. The converter only turns a cell into a JSON number when nothing can be lost:

  • CSV

    42, -3.5

    JSON

    Become numbers, because they read back exactly the same.

  • CSV

    02134, 1e5, 4111111111111111111

    JSON

    Stay strings. A number would drop the leading zero, rewrite the exponent or round an ID longer than JavaScript can hold, so ZIP codes, phone numbers and order IDs come through unchanged.

  • CSV

    true, null

    JSON

    Stay strings too. Change them in the JSON if your code expects booleans or null.

  • CSV

    ,,

    JSON

    An empty cell is an empty string, and a short row gets empty strings for its missing columns, so every object has the same keys.

The header row

Handled

  • Spaces around a column name are trimmed
  • An empty column name becomes column_3, numbered by its position
  • A repeated name gets its position added, so two email columns become email and email_4

Not done

  • Guess whether the first row is a header: it always is
  • Build nested objects from names like address.city
  • Read semicolon or tab separated files: use the TSV to JSON converter for tabs

Need the CSV back?

The JSON to CSV converter writes an array of objects back to rows, with nested objects as dot-path columns.

CSV to JSON questions

Click Open file and pick the .csv, or drop the file on the input window. It is read in your browser and converted straight away; Download saves the result as a .json file.

Because turning it into a number would change it: a leading zero, an exponent or more digits than JavaScript can store exactly. Plain numbers such as 42 or 19.99 become JSON numbers.

Yes, when the field is in double quotes, which is how Excel, Google Sheets and most databases export it. A quote inside such a field is written twice: "".

The output is already indented with two spaces. To re-indent or validate JSON from elsewhere, use the JSON beautifier; to shrink it to one line, the JSON minifier.

No. Converting runs in your browser, and an opened file is read there too.