CSV to JSON Converter

Convert CSV to JSON in your browser, with the delimiter detected and numbers typed for you. Free, no sign-up, nothing uploaded.

CSV input

Paste or type CSV, drop a file here, or open one. Nothing is uploaded.

Options

More options

JSON output

Why convert CSV to JSON?

Spreadsheets and databases export CSV, but web apps, APIs, NoSQL databases and test fixtures want JSON. Doing it by hand goes wrong in familiar ways: a comma inside a quoted name splits a row, a line break inside a cell starts a new record, a semicolon file from European Excel turns into one long column, and a ZIP code loses its leading zero. This converter follows the CSV standard, works out the delimiter, gives each column one consistent type and shows you the table before you copy the JSON.

How to use it

  1. Paste CSV, drop a .csv, .tsv or Excel file onto the box, or press Open file. Cells copied from Excel or Google Sheets can be pasted directly.
  2. Check the Preview: the delimiter is detected (comma, semicolon, tab or pipe) and the first row supplies the keys.
  3. Pick an Output layout: array of objects, array of arrays, JSON Lines, or an object keyed by the first column.
  4. Untick or reorder columns under Choose and order columns, and set empty cells or nesting under More options if you need to.
  5. Press Copy or Download .json.

A worked example

Here is a small CSV with the usual traps: a name containing a comma (so it's quoted), a quote inside a quoted field (written doubled), a ZIP code with a leading zero, Excel-style TRUE, and empty cells.

id,name,zip,member,balance,note
1,"Lopez, Maria",02134,TRUE,1250.50,"Said ""call me Mia"""
2,Tom Chen,94103,false,,

With the default settings it becomes:

[
  {
    "id": 1,
    "name": "Lopez, Maria",
    "zip": "02134",
    "member": true,
    "balance": 1250.50,
    "note": "Said \"call me Mia\""
  },
  {
    "id": 2,
    "name": "Tom Chen",
    "zip": "94103",
    "member": false,
    "balance": null,
    "note": ""
  }
]

The quotes around Lopez, Maria are CSV syntax, not part of the name, and the doubled quote becomes a single quote, escaped the JSON way. id and balance hold only plain numbers, so they become numbers, and 1250.50 keeps its trailing zero. member becomes true and false. zip stays text in both rows because 02134 can't be a number without losing its zero, and a column is converted only when every value agrees. Tom's empty balance becomes null, so the column stays numeric, while his empty note is an empty string; under More options empty cells can always be "" or null, or be left out.

Choose the JSON layout

The four JSON output layouts
OutputLooks likeUse it for
Array of objects (default)[{"id": 1, "name": "Ana"}, …]APIs, JavaScript, most programs
Array of arrays[["id", "name"], [1, "Ana"], …]Compact tables, charts, header-less data
JSON Lines (NDJSON){"id":1,"name":"Ana"} — one per lineBigQuery, mongoimport, Elasticsearch bulk, logs
Object keyed by first column{"1": {"name": "Ana"}, …}Lookups by ID; with two columns, translation files

Array of arrays puts each row on one line, header first, which keeps large tables readable. In the keyed layout, a row that repeats an earlier key replaces it (you're told how many did), and with exactly two columns each key maps straight to its value, the shape translation files and lookup tables use: {"hello": "Hola", "bye": "Adiós"}.

How numbers, true/false and null are detected

CSV has no types; every cell is text. With Detect numbers and true/false on, values become JSON numbers, booleans and null only when that is safe:

CSV values and the JSON they become
In the CSVIn the JSONWhy
42, -7, 3.50, 1e542, -7, 3.50, 1e5Numbers, written exactly as in the CSV
TRUE, true, Falsetrue, true, falseBooleans, in a column of only true/false values
null, NULLnullIn any column
02134, 007"02134", "007"Leading zeros: a ZIP code or ID, kept as text
1,234.50 or $5"1,234.50", "$5"Separators and symbols: text
12345678901234567890"12345678901234567890"Too long to be an exact number: text
2024-03-05"2024-03-05"Dates stay text (JSON has no date type)
(empty)null or ""null in number and true/false columns, "" in text; or your choice under Empty cells

Types are decided per column. If a column mixes 94103 and 02134, or 7 and N/A, the whole column stays text, so code reading the JSON never meets a field that is sometimes a number and sometimes a string. The column list shows what each column became, and a note names columns that look numeric but stayed text. A column of US ZIP codes or phone numbers may hold nothing but digits and still not be a quantity: under Choose and order columns, switch its type from number to text to keep the values as strings. Numbers that a 64-bit float can't hold exactly, such as 19-digit IDs, are always kept as strings, because JavaScript and most JSON readers would round them.

Nested JSON from column names

Set Nest keys to dots and the columns address.city and address.zip merge into one "address": { … } object, while tags[0] and tags[1] (or tags.0, tags.1) become a "tags" array. Choose slashes for headers written like address/city. These are the column names the JSON to CSV Converter writes when it flattens JSON, so data can go to a spreadsheet, be edited, and come back with its original shape.

Delimiters, quotes and line breaks

  • Quoted fields (RFC 4180): a value in double quotes may contain the delimiter, line breaks, and quotes written as "". Spaces between a delimiter and an opening quote, as in a, "b", are ignored.
  • Line endings: Windows (CRLF), Unix (LF) and old Mac (CR) files all work, even mixed in one file. Blank lines are skipped.
  • Delimiter detection reads the first rows and picks the separator that gives a consistent number of columns, ignoring separators inside quotes. A first line such as sep=;, which Excel understands, is honored and dropped.
  • Encodings: files are read as UTF-8, with or without a byte-order mark, and as UTF-16 when they start with one (Excel's Unicode Text export); older Excel exports fall back to Windows-1252, so accented names come through intact.
  • Problems are pinpointed: a quoted field that never closes stops the conversion and shows its line and column; rows with a different number of fields from the header are converted with a warning naming the first one, which usually means an unquoted delimiter inside a value.

From Excel or Google Sheets to JSON

Open an Excel workbook (.xlsx, .xls), an OpenDocument spreadsheet (.ods) or a Numbers file directly: its first sheet is read in your browser and converted like a CSV, and if the workbook has several sheets a Sheet menu lets you pick another. Numbers come through as values rather than as displayed, so an amount shown as $1,234.50 becomes 1234.5 and 25% becomes 0.25, while codes formatted with leading zeros, such as ZIP codes shown as 02134, keep them. Dates in the default date format become yyyy-mm-dd, and data that starts lower down or further right in the sheet is found on its own. For a quick job, select cells in Excel or Google Sheets, copy them and paste them into the box: copied cells arrive tab-separated and are detected as such. From Google Sheets you can also use File › Download › Comma-separated values, and to turn spreadsheets into other spreadsheet formats there's the Spreadsheet Converter. To check or minify the JSON afterwards, use the JSON Formatter & Validator, and to show the same data as a table in a README or an AI prompt, CSV to Markdown Table.

Frequently Asked Questions

How do I convert CSV to JSON?

Paste your CSV into the box, drop a .csv or .tsv file onto it, or press Open file. The JSON appears straight away, with a preview of the table underneath. The delimiter is found for you and the first row becomes the keys. Pick a layout if you need something other than an array of objects, then press Copy or Download .json.

How do I convert an Excel file to JSON?

Open the workbook directly: .xlsx, .xls, .ods and Numbers files are read in your browser, and the first sheet is converted like a CSV, with a Sheet menu to pick another if there are several. You can also select cells in Excel or Google Sheets, copy them and paste them into the box: copied cells arrive tab-separated, and the tab delimiter is detected. Or save the sheet as CSV UTF-8 in Excel (File, Save As) and open that.

Does it convert numbers and true/false values?

Yes, with Detect numbers and true/false on (the default). A column becomes numbers only when every value in it is a plain number written the JSON way, so ZIP codes such as 02134, phone numbers, amounts with thousands separators and IDs too long to be exact stay text, and a column never ends up half numbers and half strings. TRUE, true and False become booleans, and null becomes null. To keep one column as text anyway, such as US ZIP codes or phone numbers, set its type to text in the column list; to keep every value as a string, turn detection off.

Can I create nested JSON from CSV?

Yes. Set Nest keys to dots (or slashes) and column names such as address.city and address.zip are combined into one address object, while tags[0] and tags[1] (or tags.0 and tags.1) become a tags array. This is the reverse of how the JSON to CSV converter flattens data, so the two round-trip. If two column names clash, as a and a.b do, the clashing value keeps its full column name so nothing is lost.

What is the difference between a JSON array and NDJSON (JSON Lines)?

A JSON array wraps all records in one [ … ] value, which is what most APIs, JavaScript code and config files expect. NDJSON, also called JSON Lines, puts one complete JSON object on each line with nothing around them, so tools can read or append records one at a time. BigQuery, MongoDB's mongoimport, Elasticsearch's bulk API and many log pipelines use it. Choose JSON Lines (NDJSON) under Output for that format.

My CSV uses semicolons. Will that work?

Yes. With the delimiter on Auto, the converter reads the first rows and picks the separator that splits them most consistently: comma, semicolon, tab or pipe. Quoted text is respected, so commas inside quotes never mislead it. Excel in many European countries saves semicolon-separated CSV because the comma is used as the decimal mark, and a first line such as sep=; is understood too. You can always set the delimiter yourself.

What if my CSV has no header row?

Untick First row is the header. The keys are then named column_1, column_2 and so on, or choose Array of arrays as the output to get plain rows without keys. If a header cell is blank, that column is named by its position, and duplicate names get a number (name_2) so no value is overwritten.

How are empty cells converted?

By default an empty cell becomes null in a column of numbers or true/false values, so the column keeps a single type, and an empty string in a text column. Under Empty cells you can make them always an empty string or always null, or leave the key out of that object entirely, which keeps the JSON small for sparse data. In array layouts every position has to stay, so left-out cells become null there.

Why do I get an error about an unclosed quoted field?

A field that starts with a double quote must end with one, and a quote inside a quoted field must be doubled (""). If a closing quote is missing, everything after it would silently merge into one giant cell, so the converter stops and shows the line and column where the quoted field starts. Rows with more or fewer fields than the header are converted, with a warning naming the first such line.

Is my CSV uploaded anywhere?

No. Everything runs in your browser, in a background thread on your own device; the page has no server to send data to. The current input is kept only in this browser tab, so it survives moving around the site, and is forgotten when you close the tab. Your settings are remembered on this device.

How do I convert CSV to JSON in Python or on the command line?

In Python: import csv, json, then rows = list(csv.DictReader(open("data.csv", newline="", encoding="utf-8"))) and json.dump(rows, open("data.json", "w"), indent=2). Every value stays a string unless you convert it yourself. On the command line, Miller does it in one step: mlr --icsv --ojson cat data.csv. This page adds type detection, nesting and a preview without any code.

Advertisement