U.UtilityApp
🔄 ConvertersFree · No signup

CSV to JSON Converter

Convert CSV data into a JSON array of objects. The first row becomes the keys; quotes and commas are handled.

What the sample turns into

The first row is always used as the keys, and every row after it becomes one object in a JSON array. The output is indented with two spaces:

name,city,age Ada,London,36 Alan,Maida Vale,41
[ { "name": "Ada", "city": "London", "age": 36 }, { "name": "Alan", "city": "Maida Vale", "age": 41 } ]

Notice that 36 and 41 came out as numbers, without quotes, while the names and cities stayed text. That guess is made separately for every cell, which matters in the next section.

How each cell is typed

A cell becomes a JSON number whenever JavaScript can read it as one. Otherwise it stays a string. Booleans and null are never produced. Here is what the converter does with some common values:

Cell in your CSVValue in the JSON
3636
19.9019.9
021342134
1e31000
0x1F31
Infinitynull
true"true"
(one space)0
(empty)""
n/a"n/a"

Three of these catch people out. Codes with leading zeros, like ZIP codes and phone numbers, lose them. A cell holding only a space becomes 0. And putting a value in quotes in the CSV does not protect it: "42" still becomes 42. If you need those columns as text, fix them in the JSON afterwards, or convert them in your own code instead.

Short rows, long rows and odd headers

Rows don't have to match the header exactly. Missing cells become empty strings, and extra cells past the last header are dropped without a warning:

id,name,email 1,Ada 2,Alan,alan@example.com,extra
[ { "id": 1, "name": "Ada", "email": "" }, { "id": 2, "name": "Alan", "email": "alan@example.com" } ]

The word extra is gone. A few header problems also change the keys:

  • A blank header becomes column2, column3 and so on, numbered by position.
  • A repeated header keeps only the value from its last column.
  • A space after a comma stays in the key, so name, city gives you a key called " city" with a leading space.

Tidy the header row before converting and you avoid all three.

Separators and line endings it accepts

Only commas separate fields. A semicolon-separated export comes out as one long key such as "name;age" holding the whole row. Re-export with commas, or replace the semicolons first if no value contains one.

Windows (CRLF) and Unix (LF) line endings both work, blank lines are skipped, and a line break inside a quoted cell is kept as \n in the string.

Frequently asked questions

Why do I get an empty array?+

Your input has only one row. That row is used as the header, so there are no data rows left to turn into objects. Add at least one line of values under it.

Can it convert tab-separated (TSV) files?+

Not directly, because only commas are treated as separators. You can swap the tabs for commas first, but only if no value contains a comma, otherwise those values split into extra columns.

Will true and false become JSON booleans?+

No. Words like true, FALSE or yes stay as strings. If your code needs real booleans, convert them after parsing, for example by comparing the string to true.

Can I get nested JSON from dotted headers like address.city?+

No. A header such as address.city becomes a key with a dot in its name, not a nested object. Every row converts to a flat object with one key per column.

Guides & deep dives

Embed this tool on your website

Free to use on blogs, school sites and intranets. Paste this code into your page's HTML; please keep the credit line.

<iframe src="https://utilityapp.lat/embed/convert/csv-to-json" title="CSV to JSON Converter" width="100%" height="600" style="border:0;max-width:760px" loading="lazy"></iframe>
<p style="font-size:13px"><a href="https://utilityapp.lat/convert/csv-to-json">CSV to JSON Converter</a> by UtilityApp</p>