When to convert CSV to JSON
CSV is how data leaves spreadsheets, databases and SaaS dashboards; JSON is how it enters APIs, front-end code and document databases. Typical jobs:
- Turning an Excel or Google Sheets export into seed data or a test fixture.
- Posting rows to a REST endpoint, a headless CMS or Firestore.
- Inspecting a CSV in the JSON formatter’s tree or table view, or querying it with JSONPath.
How rows are parsed
Parsing follows RFC 4180, the rules Excel and most databases use:
- Fields are separated by commas. Quoted fields may contain commas, line breaks and doubled quotes (
""for one"). - Windows (CRLF), Unix (LF) and old Mac (CR) line endings are all accepted, even mixed in one file, and a UTF-8 byte-order mark is ignored.
- Blank lines are skipped.
Semicolon-separated files, which Excel writes in many European locales, are not auto-detected: each line would end up in a single column. Replace the semicolons first, or export with commas. For tab-separated data, use TSV to JSON.
First row is a header
With First row is a header on (the default), the first row supplies the keys and every following row becomes an object, with keys in column order. Header problems are repaired and reported rather than failing:
- An empty header cell becomes
column_3(using its position). - A repeated header such as a second
idbecomesid_2. - A row with fewer fields than the header gets
nullfor the missing ones; a row with extra fields gets additional keys namedcolumn_N. Each ragged row produces a warning with its line number.
Switch the option off to get an array of arrays instead, where the first row is ordinary data. That suits files with no header or with headers you plan to rename.
Detect numbers, booleans and empty values
CSV has no types; everything is text. With Detect numbers, booleans and empty values on (the default), cells are typed conservatively:
- An empty cell becomes
null. - Exactly
trueorfalse(lower case) becomes a boolean;TRUEorYesstay strings. - A cell becomes a number only if it is written in plain decimal form and a double can hold it exactly. So
42,-12.75and1520.50become numbers, and the number keeps its written spelling (1520.50is not shortened to1520.5). - ZIP codes and IDs with leading zeros (
00123), phone numbers with a plus (+4412), exponent forms (1e5),-0, and integers too large for JavaScript (12345678901234567890) all stay strings, so nothing is silently rounded or stripped.
Switch detection off to keep every cell as a string, with empty cells as "".
Tips
- If accented characters look garbled, the file was probably saved in a legacy Windows encoding; see CSV and Excel encoding.
- To go back to CSV, use JSON to CSV, which flattens nested objects into dotted columns.
- Everything, including type detection, is computed by JavaScript in your browser tab.
Examples
Customer export with quoted fields
The quoted comma and doubled quotes are decoded, ids and balances become numbers, and 1520.50 keeps its trailing zero.
id,name,city,joined,balance
1,"Tan, Aisha",Singapore,2024-03-11,1520.50
2,Ben Okafor,Lagos,2023-11-02,88.00
3,"Chloé ""CJ"" Martin",Paris,2025-01-20,-12.75
[
{
"id": 1,
"name": "Tan, Aisha",
"city": "Singapore",
"joined": "2024-03-11",
"balance": 1520.50
},
{
"id": 2,
"name": "Ben Okafor",
"city": "Lagos",
"joined": "2023-11-02",
"balance": 88.00
},
{
"id": 3,
"name": "Chloé \"CJ\" Martin",
"city": "Paris",
"joined": "2025-01-20",
"balance": -12.75
}
]
Values that must stay text
Leading-zero ZIP codes, phone numbers and 20-digit IDs stay strings, the empty discount becomes null and active becomes a boolean.
sku,zip,phone,active,discount,legacy_id
KB-104,00123,+6591234567,true,,12345678901234567890
MS-220,04567,+2348012345678,false,0.15,98765432109876543210
[
{
"sku": "KB-104",
"zip": "00123",
"phone": "+6591234567",
"active": true,
"discount": null,
"legacy_id": "12345678901234567890"
},
{
"sku": "MS-220",
"zip": "04567",
"phone": "+2348012345678",
"active": false,
"discount": 0.15,
"legacy_id": "98765432109876543210"
}
]
No header row
Without a header each row becomes an array of values, with dates as strings and durations as numbers.
2026-09-14,checkout,1840
2026-09-14,search,95
2026-09-15,checkout,1720
[
[
"2026-09-14",
"checkout",
1840
],
[
"2026-09-14",
"search",
95
],
[
"2026-09-15",
"checkout",
1720
]
]
Common errors and how to fix them
| Error | Cause | Fix |
|---|---|---|
This quoted field is never closedExplained | A field starts with a quote that has no matching closing quote, so the rest of the file looks like one field. | Add the closing quote, and write any quote inside a quoted field as two quotes (“”). |
Unexpected text after a closing quoteExplained | A field such as “Tan” Aisha has text after its closing quote. | Quote the whole field and double the inner quotes: “”“Tan”" Aisha". |
Row has 4 fields, expected 3; the extra fields are kept in additional columnsExplained | A warning: some rows have more or fewer fields than the header, often because of an unquoted comma. | Quote fields that contain commas, or accept the column_N keys and null values. |
Duplicate header "id" renamed to "id_2" | Two columns share a header name, and JSON objects cannot have two identical keys. | Rename the columns in the CSV if you want different key names. |
Frequently asked questions
Why did 00123 stay a string?
Turning it into a number would drop the leading zeros, which matters for ZIP codes, account numbers and SKUs. Only plain decimals that convert without change become numbers.
How are empty cells represented?
As null when type detection is on, and as an empty string when it is off. Missing trailing fields are always null.
Can it read semicolon-separated CSV?
No, this converter splits on commas only. Replace the semicolons with commas or re-export the file with a comma separator.
Does it handle line breaks inside a cell?
Yes, as long as the cell is quoted. The line break is kept inside the JSON string as \n.
Is my CSV uploaded?
No. Parsing and typing run locally in your browser; no request is made with the file contents.