Convert CSV to JSON locally in your browser

Convert CSV to JSON without uploading your file. Handle delimiters, quotes, number types, ragged rows and large files, with JavaScript and Python examples.

Runs in your browser. No account required.

CSV is how spreadsheets and databases export tables. JSON is what most APIs, JavaScript code and config files expect. This guide shows how to convert one to the other without uploading your file anywhere, and how to fix the problems that usually break the conversion: delimiters, quotes, number types, ragged rows and large files.

What the conversion produces

The first row of the CSV becomes the keys. Every row after it becomes one JSON object.

name,city,age
Ada,London,36
Lin,Pune,29

becomes:

[
  { "name": "Ada", "city": "London", "age": 36 },
  { "name": "Lin", "city": "Pune", "age": 29 }
]

If your file has no header row, add one before converting. Otherwise your first data row will be used as the keys.

The quick way: convert in the browser

  1. Open the CSV to JSON converter.
  2. Paste your CSV, or drag a .csv file onto the input box.
  3. If your data has codes with leading zeros or very long IDs, tick Keep all values as text.
  4. Select Convert to JSON, then copy the result or download it as a .json file.

The file is read and converted by JavaScript on your device. Nothing is sent to a server, so it is safe to use with customer exports, payroll sheets or anything else you would not paste into a random website. You can check this yourself: open your browser's developer tools, switch to the Network tab and run a conversion. No request carries your data.

Delimiters: commas, semicolons, tabs and pipes

"Comma-separated" files are often not separated by commas. Excel in many European locales writes semicolons, because the comma is the decimal separator there. Database tools often export tabs (.tsv) or pipes.

The converter detects the delimiter automatically. If you are writing your own code, check it first: open the file in a text editor and look at the first line. If every row comes out as a single long key, the delimiter was guessed wrong.

Quotes, commas inside values and line breaks

A value that contains the delimiter, a quote or a line break must be wrapped in double quotes. A quote inside a quoted value is written twice:

id,comment
1,"Arrived late, box damaged"
2,"She said ""fine"" and left"
3,"Line one
line two"

Spreadsheet exports follow this rule, and the converter reads all three rows correctly. Hand-written CSV often does not. An unclosed quote is the most common reason a conversion fails or swallows the rest of the file. Search for a value that starts with " but never ends with one.

Numbers, true/false and text

CSV has no types; every value is text. Converters have to decide whether 36 should become the number 36 or the string "36". By default Convertr turns values that look like numbers into JSON numbers, and true/false into booleans. Everything else, including dates, stays a string.

That is usually what you want, with two exceptions to check before you rely on the output:

If your data has either, tick Keep all values as text in the converter. Every value then stays a string exactly as written, so 00501 stays "00501". The code examples below do the same.

Rows with missing or extra values

Real exports are often ragged: a row has fewer values than there are headers, or a stray trailing comma adds one more. The converter fills missing values with an empty string and drops values beyond the last header, so one bad row does not stop the whole file. Blank lines are skipped.

Two header problems are worth fixing in the CSV itself. If two columns share a name, the second overwrites the first in each object, so rename them to be unique. If a header cell is empty, its values end up under an empty key.

Large files

Because nothing is uploaded, there is no file-size limit, only your device's memory. Files of a few megabytes, tens of thousands of rows, convert almost instantly. Files of hundreds of megabytes can make a browser tab slow or run out of memory, because the whole file and the whole JSON result are held at once. For those, use a script that streams the file instead.

Doing it in code

In JavaScript, Papa Parse is the standard CSV parser. With header: true it returns one object per row and keeps every value as a string, which avoids the leading-zero problem:

import Papa from 'papaparse'

const { data, errors } = Papa.parse(csvText, {
  header: true,
  skipEmptyLines: 'greedy'
})

if (errors.length) console.warn(errors)
const json = JSON.stringify(data, null, 2)

In Python, the standard library is enough. The utf-8-sig encoding removes the invisible byte-order mark that Excel adds to UTF-8 files, which otherwise ends up in your first key:

import csv, json

with open('data.csv', newline='', encoding='utf-8-sig') as f:
    rows = list(csv.DictReader(f))  # add delimiter=';' for semicolon files

with open('data.json', 'w', encoding='utf-8') as f:
    json.dump(rows, f, indent=2, ensure_ascii=False)

Troubleshooting

Every row is one long key with commas or semicolons in it
The delimiter does not match. Check the first line of the file and set the delimiter explicitly.
The conversion stops partway, or one value contains several rows
There is an unclosed double quote just before the point where it breaks.
The first key starts with a strange character
The file starts with a UTF-8 byte-order mark. Re-save it as "UTF-8" rather than "UTF-8 with BOM", or read it with utf-8-sig in Python.
Accented letters show as é or similar
The file is not UTF-8. Re-export it as UTF-8 from your spreadsheet.
Codes lost their leading zeros
The value was converted to a number. Tick Keep all values as text and convert again.

Related tools

View all Convertr tools