json.cihat.dev

CSV to JSON converter

Convert CSV to JSON online: paste a CSV or open an exported spreadsheet and get an array of objects keyed by the header row, or plain arrays. The delimiter is detected and nothing is uploaded.

Output

How to use it

  1. Paste CSV text or open a .csv or .tsv file. The delimiter is detected; change it if the preview looks wrong.
  2. Keep First row is the header on when the first line holds column names. They become the keys of each object.
  3. Leave Read numbers, true, false and empty cells on to get 42 instead of "42", or switch it off to keep every cell as text.
  4. Copy the JSON or download it as data.json.

A worked example

A semicolon export from Excel, where one name contains the delimiter inside quotes, one city is empty and the phone numbers start with zero:

id;name;city;active;phone
1;"Yılmaz; Ayşe";İzmir;true;05321234567
2;Can;;FALSE;

The semicolon is detected, and with value reading on the result is:

[{"id": 1, "name": "Yılmaz; Ayşe", "city": "İzmir", "active": true, "phone": "05321234567"}, {"id": 2, "name": "Can", "city": null, "active": false, "phone": null}]

The quoted semicolon stays inside the name. The empty cells became null, and FALSE became false. The phone number stayed text, because a leading zero is not allowed in a JSON number and dropping it would change the value.

Quotes, commas and line breaks inside cells

The parser follows RFC 4180, the CSV format Excel, Google Sheets and most databases write: a cell in double quotes may hold the delimiter, a line break, or a quote written twice (""). Lines may end in CRLF or LF. A semicolon file from a European Excel and a tab-separated export work the same way.

Detection looks at the first lines and picks the delimiter (comma, semicolon, tab or pipe) that splits them into the most consistent number of columns. A file with a single column has no delimiter to find; choose one by hand if the result looks wrong.

What becomes a number

CSV has no types: every cell is text. JSON has strings, numbers, booleans and null, and RFC 8259 defines exactly how a number is written. With value reading on, a cell becomes a number only when it is written that way, such as 12, -3.5 or 1e6. Values with a leading zero (007), a thousands separator or a decimal comma stay text, because turning them into numbers would change them. Integers above 9,007,199,254,740,991, the range RFC 8259 calls interoperable, also stay text, so a 19-digit ID is not rounded. true, false and null are read in lower case, upper case or with a capital first letter. Empty cells become null.

JSON has no date type, so dates stay strings exactly as written. Convert them in your code once you know their format.

CSV and JSON side by side

The two formats carry the same records in different ways:

CSVJSON
SpecificationRFC 4180 (Informational, 2005)RFC 8259 (Internet Standard, 2017)
Media typetext/csvapplication/json
Value typesText onlyString, number, boolean, null, object, array
NestingNone; one flat row per recordObjects and arrays to any depth
Column namesOptional header lineKeys repeated in every object

Shapes of output

Array of objects uses the header row as keys and is what most APIs and seed scripts expect. Array of arrays keeps the rows as lists, the header included, which is smaller and keeps duplicate or empty column names untouched. With Nest dotted headers, a column named address.city becomes {"address": {"city": …}}, the reverse of what JSON to CSV does when it flattens.

To look through a large CSV before converting it, sort and filter it in the CSV viewer. To check the JSON you get, open it in the JSON viewer.

Questions people ask

Is my CSV uploaded?

No. The file is read and converted in your browser; nothing is sent to a server.

How do I convert an Excel file to JSON?

Save the sheet from Excel as CSV UTF-8, then open that file here. The delimiter Excel used, comma or semicolon, is detected.

Can I get nested JSON from CSV?

Yes. Turn on Nest dotted headers and a column named address.city becomes {"address": {"city": …}}.

Why did a number stay in quotes?

Because converting it would change it: a leading zero, a thousands separator, a decimal comma, or an integer too long for JavaScript to hold exactly. Switch off value reading to keep every cell as text.

What if two columns have the same name?

The second one becomes name_2, the third name_3, so no value is lost.

My file has no header row. What then?

Turn off First row is the header. Columns are named column1, column2 and so on, or choose Array of arrays.