JSONToonPro
JSON tool

CSV to JSON Converter

Convert CSV to JSON online in seconds. Paste CSV data and get a JSON array of objects instantly: the first row becomes the keys, and every following row becomes an object. Quoted fields and custom delimiters are handled correctly, and everything runs 100% client-side, so your data never leaves your browser.

100% client sideInstant resultNo data sent
Delimiter
4 × 8
Input· CSV
287 chars5 lines
Output· JSON
753 chars42 lines

How the Header Row Becomes Object Keys

Converting CSV to JSON is mostly a mapping exercise. The first line of the file is read as a list of column names, and every following line becomes one object whose keys are those names and whose values are the fields in matching positions. An array of those objects is the output.

This is why the header row carries so much weight. It is the schema of the file, and any oddity in it propagates into every single record. Column names with spaces, trailing whitespace, or mixed casing all become awkward object keys, so it is worth trimming and normalising them before the conversion rather than fixing thousands of objects afterwards.

If the header uses dot notation, unflattening can rebuild nested structure: a column called address.city puts city inside an address object instead of creating a literal key with a full stop in it. That is what makes a JSON to CSV to JSON round trip come back to where it started.

Side by Side Example

A small inventory export, converted with type inference and unflattening turned on.

CSV input

sku,title,price,in_stock,supplier.name
AX-9,Desk lamp,24.50,true,Northlight
BX-2,"Chair, folding",89.00,false,Peak
CX-7,Rug,,true,Northlight

JSON output

[
{ "sku": "AX-9", "title": "Desk lamp",
"price": 24.5, "in_stock": true,
"supplier": { "name": "Northlight" } },
{ "sku": "BX-2", "title": "Chair, folding",
"price": 89, "in_stock": false,
"supplier": { "name": "Peak" } },
{ "sku": "CX-7", "title": "Rug",
"price": null, "in_stock": true,
"supplier": { "name": "Northlight" } }
]

Two details are worth noticing. The quoted title in row two keeps its comma and loses its quotes, because the quotes were transport syntax rather than content. And 24.50 became 24.5, because JSON numbers have no concept of trailing decimal places.

Type Inference and When to Skip It

Every value in a CSV file is text. Type inference is the step that decides which of those text values should become JSON numbers, booleans, or null.

Cell contentInferred asRisk
42NumberLow, unless it is a zero padded code
3.14NumberLow
007String if padding is preservedHigh, inference may strip to 7
true / falseBooleanLow, but TRUE and yes need explicit rules
(empty)null or empty stringAmbiguous, an empty string and a missing value are not the same thing
1e5Number 100000Product codes and batch ids get mangled
+441234String or numberLeading plus is dropped by many parsers

There is a real argument for leaving everything as strings. Identifiers, phone numbers, postcodes, account numbers, and version strings are all data that looks numeric but must never be arithmetic. If the JSON is going straight into a system that will validate and cast it anyway, strings in and strings out is the safest default. Turn inference on when the JSON is being consumed directly by application code that expects real numbers.

Quoted Fields, Delimiters, and Embedded Newlines

A correct CSV parser is a small state machine, not a call to split. It has to track whether it is currently inside a quoted field, because inside quotes the delimiter and the line break are ordinary characters.

One record spanning three physical lines

id,note
1,"First line
second line
third line"

That file has four physical lines but only two records. A doubled quote inside a quoted field means a literal quote character, so "He said ""no""" holds the value He said "no". Anything that splits on the newline before understanding quotes will produce three broken rows and no error message.

Header and Row Edge Cases

Edge caseWhat goes wrongSensible handling
Duplicate header namesThe later column silently overwrites the earlier oneSuffix duplicates as name, name_2, name_3
Empty header cellProduces an object key of empty stringFall back to column_1, column_2 by position
Ragged row, too few fieldsMissing keys, uneven objectsPad with null so every object has the same shape
Ragged row, too many fieldsExtra values have no keyCollect the surplus into an _extra array or reject the row
Blank line in the middleEmits an object of all nullsSkip empty lines by default
Comment lines starting with #Parsed as dataEnable a comment prefix option before parsing
CRLF versus LF endingsTrailing carriage return glued onto the last fieldNormalise line endings before splitting

The Byte Order Mark Bug

This one deserves its own section because it wastes more time than anything else on the list. Files exported from Excel on Windows often begin with a UTF-8 byte order mark, three invisible bytes (EF BB BF) before the first character. Most editors hide it. Your parser does not.

What you see and what you get

You see: id,name,email
You get: { "\ufeffid": 1, "name": ... }
 
row.id is undefined
row["\ufeffid"] is 1

The symptom is unmistakable once you know it: only the very first column comes back undefined and every other column is fine. The fix is to strip a leading U+FEFF from the file before parsing, or to decode the file with an encoding that consumes the mark. If you are producing files for Excel rather than consuming them, the reverse applies, since Excel needs that mark to recognise UTF-8 at all.

Once your CSV is clean JSON, the next step is usually a schema or a type. Browse the full converter collection for JSON to TypeScript to generate interfaces from the result, JSON Schema for validation rules, and JSON to CSV when you need to send the data back the other way.

Frequently asked questions

4 answers
The converter reads the first row of your CSV as the column headers and uses those headers as JSON keys. Every following row becomes one JSON object, with each cell mapped to its column key. The result is a JSON array of objects, the same shape most APIs and JavaScript applications expect. Paste your CSV and the JSON output appears instantly.

More JSON Tools

About the CSV to JSON Converter

CSV is the universal export format for spreadsheets, databases, and analytics tools, but modern APIs and JavaScript applications speak JSON. This CSV to JSON converter bridges that gap: paste a CSV export from Excel, Google Sheets, or any database dump, and get a clean JSON array of objects ready for your code. The parser follows standard CSV quoting rules, so commas and line breaks inside quoted fields are preserved, and custom delimiters (semicolon, tab, pipe) cover regional Excel exports and TSV files. Because the converter is free and runs entirely in your browser, it is a safe choice for customer lists, financial exports, and any data you would rather not upload to a server.