Converting CSV to JSON correctly
CSV looks simple enough to split on commas and line breaks, but real files break that approach quickly: a name like "Hopper, Grace" contains the delimiter, an address field contains a line break, and a quote inside a quoted field is written as two quotes (""). This converter uses a proper RFC 4180 parser that handles all of these, plus CRLF and LF line endings, a trailing newline and the byte order mark Excel adds to UTF-8 exports.
The delimiter is detected automatically by checking which of comma, semicolon, tab and pipe splits the first rows into a consistent number of columns — useful for European Excel exports, which use semicolons. With the first row as the header, each line becomes an object whose keys are the column names; duplicate or empty header names are renamed and reported rather than silently overwriting data.
Every CSV value is text. Type detection turns 42, 3.14, true and null into real JSON numbers, booleans and null, while keeping values like the zip code 02134 and 19-digit IDs as strings so nothing is corrupted. Rows with too few or too many fields are flagged with their line numbers.
How to use the CSV to JSON Converter
- Paste CSV, open a
.csvor.tsvfile, or click Sample. - Leave the delimiter on Auto-detect or choose one, and untick First row is the header if your file has no header.
- Choose the output shape — array of objects, array of arrays, an object keyed by a column such as
id, or an object of column arrays — and how empty cells should appear. - Review any warnings about mismatched rows or header names, then copy the JSON or download
data.json.
Example
With type detection on, this CSV:
id,name,active,zip
1,"Hopper, Grace",true,02134
// becomes
[
{
"id": 1,
"name": "Hopper, Grace",
"active": true,
"zip": "02134"
}
]Choosing an output shape
- Array of objects — the usual choice for APIs, fixtures and importing into a database:
[{"id": 1, "name": "Ada"}]. - Array of arrays — compact and order-preserving, with the header as the first row; good for charting libraries and data tables.
- Object keyed by a column —
{"1": {...}, "2": {...}}for fast lookups by ID. Repeated key values are reported because later rows replace earlier ones. - Object of column arrays —
{"id": [1, 2], "name": ["Ada", "Grace"]}, the columnar layout used by many plotting and dataframe tools.
Common CSV problems and what they mean
- Every row has a different column count: the delimiter is probably wrong; try a different one or check the detected value.
- "A quoted field is never closed": a field opens with
"but the closing quote is missing, so the parser read the rest of the file into one cell. Look at the reported line. - Unexpected quote in an unquoted field: a value like
5" screenshould be written as"5"" screen". The quote is kept as-is and reported.
Frequently Asked Questions
Can I convert an Excel spreadsheet?
Save or export the sheet as CSV (File → Save As → CSV UTF-8) and paste or open it here. Excel exports from some locales use semicolons, which auto-detect handles.
Why did my zip codes or IDs stay as strings?
Values with leading zeros would lose them as numbers (02134 would become 2134), and integers above 9,007,199,254,740,991 cannot be stored exactly in JavaScript. Keeping them as strings preserves the original data.
Does it handle line breaks inside cells?
Yes. A quoted field can contain line breaks, delimiters and doubled quotes; the warnings refer to the line where each row starts, so multi-line rows are reported correctly.
How do I go the other way?
The JSON to CSV Converter flattens nested JSON into columns and writes RFC 4180-compliant CSV, with an option to add the BOM Excel needs.
Is my file uploaded?
No. The file is read and parsed in your browser and never leaves your device, so it is safe for customer lists and other private exports.