Developer Tools

CSV to JSON Converter

CSV to JSON converter that turns spreadsheet rows into a JSON array and JSON back into CSV, with comma, semicolon, tab or pipe delimiters.

Input CSV
Output JSON

This CSV to JSON converter turns rows copied from a spreadsheet, database export or analytics report into a JSON array that an API or a script can read. It also converts JSON back into CSV. Both directions run as JavaScript in your browser, so the data you paste is not uploaded.

How to convert CSV to JSON

  1. Leave the mode switch on CSV → JSON and paste your data into the Input CSV box. There is no file picker, so open a .csv file in a text editor and copy its contents, or press Try Example to load a sample.
  2. Pick the Delimiter your data uses: Comma, Semicolon, Tab or Pipe. Spreadsheet programs set to a language that writes decimals with a comma often save CSV files with semicolons.
  3. Keep First row is header ticked if the first line holds column names, and choose Array of Objects or Array of Arrays under JSON format.
  4. Leave Prettify output on for JSON indented with 2 spaces, or turn it off to get everything on one line.
  5. Click Convert. The status line reports how many rows and columns were converted, and the Copy button copies the result. There is no download button, so paste the JSON into a file if you need one.

What the options and type detection do

With a header row and Array of Objects, each data row becomes an object whose keys are the column names. Array of Arrays keeps every row as a plain list, and with the header ticked the header row stays in as the first list. Unticking First row is header always produces arrays, because objects need names for their keys.

Values are typed as they are converted. A field made only of digits, with an optional minus sign and decimal part, becomes a JSON number if it is shorter than 16 characters. The words true, false and null become JSON literals, and everything else stays a string. An empty field becomes an empty string, a row with fewer fields than the header gets null for each missing column, and fields beyond the last header column are dropped.

Quoted fields can hold the delimiter, line breaks and doubled quotes, so "Smith, John" stays one value. Spaces are not trimmed: with the header name, age and the row Jane, 28, the key becomes " age" and the value " 28", stored as text.

Example: a product list

Paste this CSV with the default settings:

sku,name,price,in_stock,zip
A-100,"Desk lamp, brass",24.50,true,02134
B-220,Notebook,3,false,

The status line reports 2 rows × 5 columns, and the output is:

[
  {
    "sku": "A-100",
    "name": "Desk lamp, brass",
    "price": 24.5,
    "in_stock": true,
    "zip": 2134
  },
  {
    "sku": "B-220",
    "name": "Notebook",
    "price": 3,
    "in_stock": false,
    "zip": ""
  }
]

Two values changed on the way. The price 24.50 became the number 24.5, which is the same value in JSON. The ZIP code 02134 became 2134, because the converter turns any short run of digits into a number and drops the leading zero, even when the field is in quotes. ZIP codes, phone numbers, account numbers and product codes that start with 0 are affected, so check those columns and put the values back as strings before you use the JSON.

Converting JSON to CSV

Click JSON → CSV and paste an array of objects or an array of arrays. For objects, the header row lists every key found anywhere in the array, in the order the keys first appear, and an object that lacks a key gets an empty cell. Null becomes an empty cell, nested objects and arrays are written into the cell as JSON text, and any value containing the delimiter, a quote or a line break is wrapped in quotes. Untick Include header row to leave the header line out.

[{"id":1,"tags":["a","b"],"meta":{"x":1},"note":null},{"id":2,"extra":"yes"}]

becomes

id,tags,meta,note,extra
1,"[""a"",""b""]","{""x"":1}",,
2,,,,yes

The input has to be an array. A single object such as {"id":1} stops with the message "JSON must be an array. Got object." Wrap it in square brackets to convert it as one row.

CSV to JSON in Python, for files with leading zeros

If you need to keep leading zeros, or the file is too large to paste comfortably, convert it with a script. Python's standard library does it in a few lines, and csv.DictReader keeps every value as a string, so 02134 stays "02134", 24.50 stays "24.50" and true stays "true".

import csv, json

with open("products.csv", newline="") as f:
    rows = list(csv.DictReader(f))

print(json.dumps(rows, indent=2))

For a quick job the page is faster: paste, convert, then open the result in the JSON formatter to browse it as a tree or to validate an edited copy. The text diff checker helps when you need to compare two exports of the same table. JSON vs CSV: which format to use and when explains which format suits which job, and the other converters and formatters are listed under developer tools.

Frequently Asked Questions

What is the difference between CSV and JSON?
CSV stores a table as plain text, one row per line, with the columns separated by a delimiter. JSON stores data as key-value pairs and arrays that can be nested inside each other, which makes it a better fit for nested data and APIs.
Does the converter support custom delimiters?
Yes. Both directions offer comma, semicolon, tab and pipe, so you can read files exported from different sources and locales and write CSV in the format your other software expects.
What happens if my CSV has missing values?
An empty field, such as the middle value in Bob,,41, becomes an empty string. If a row ends early and has fewer fields than the header, each missing column is set to null. Either way every object keeps the same keys as the header row.
Why did my ZIP codes lose their leading zero?
The converter turns every field made only of digits into a JSON number, and numbers cannot start with 0, so 02134 comes out as 2134. Quoting the value in the CSV does not prevent it. Fix those values by hand in the output, or convert the file with a script that keeps values as text.
Can I convert CSV to JSON online without uploading the file?
Yes. The page has no file upload and no server step. You paste the CSV text into the input box and the conversion runs in your browser, so the data stays on your device. To convert a .csv file, open it in a text editor, copy everything and paste it in.
Why does my JSON have only one key per row?
The delimiter setting does not match the file. If a semicolon-separated file is read with Comma selected, each line stays one field, so a header like id;city becomes a single key and every row a single string. Pick Semicolon, Tab or Pipe to match the data and convert again.