CSV to JSON Converter
Turn a spreadsheet export into an array of objects. The header row supplies the keys, and quoted fields containing commas or line breaks are parsed correctly.
Reading CSV is harder than it looks, because the format is a family of conventions rather than a single specification. This parser scans the whole document rather than splitting it into lines first, which is what lets a newline inside a quoted field stay part of that field instead of tearing the record in half. Line feed, carriage return, and the pair of them are all accepted as record separators, so files from Windows tools work without conversion.
Doubled double quotes inside a quoted field are read as one literal quote, blank lines are skipped rather than becoming rows of empty strings, and a record with fewer fields than the header gets empty strings for the remainder. What the parser deliberately does not do is guess types, which is the subject of the section below.
Every value is a string, and that is the safe choice
CSV carries no type information at all. The characters 42 in a cell could be the number forty two, a string, a product code, or a truncated identifier, and nothing in the file says which. This converter therefore emits every value as a JSON string, without exception. It is the one behaviour people most often want changed, and the one most likely to corrupt data if it were changed.
Consider what type guessing costs. A postal code column containing 07030 becomes the number 7030 and the leading zero is gone. A part number like 1E5 becomes 100000 in scientific notation. An identifier of twenty digits gets rounded past the sixteenth. A column of version strings where one row reads 1.10 becomes 1.1. Each of these is a silent, irreversible change to a value that looked like a number but was not one.
Converting types is far safer once you know what a column means, which is knowledge that lives in your code rather than in the file. Take the string output and map it deliberately, coercing the columns you know are numeric and leaving identifiers alone. It is a few lines of work and it never eats a leading zero.
What the parser does with each input
Each row is a real CSV fragment and the value this tool produces from it.
| CSV input | JSON output | Notes |
|---|---|---|
"Ada, A." | "Ada, A." | A quoted field keeps its comma. The comma does not split the field. |
"said ""hi""" | "said \"hi\"" | A doubled double quote inside a quoted field becomes one literal quote. |
"line1<LF>line2" | "line1\nline2" | A newline inside quotes stays in the value rather than ending the record. |
07030 | "07030" | A numeric looking field stays a string, so the leading zero survives. |
1E5 | "1E5" | No type guessing at all, so this stays text rather than becoming 100000. |
a,b,c / 1,2 | {"a":"1","b":"2","c":""} | A record shorter than the header gets empty strings for the missing fields. |
x,y\r\n1,2\r\n | {"x":"1","y":"2"} | Carriage return and line feed pairs are handled, so Windows files need no conversion. |
Parsing a quoted export
A file with an embedded comma, an escaped quote, and a value that looks like a number.
name,zip,note
"Ada, A.",07030,"said ""hi"""
Alan,02101,[
{
"name": "Ada, A.",
"zip": "07030",
"note": "said \"hi\""
},
{
"name": "Alan",
"zip": "02101",
"note": ""
}
]The zip code kept its leading zero because it stayed a string. Had the parser guessed types, 07030 would have become 7030 and the value would be wrong for every downstream consumer.
Common Pitfalls
You will need to convert types yourself
Numbers arrive as strings, so a sum over a column will concatenate instead of adding, and a comparison will order 100 before 20. Map the columns you know are numeric after conversion. Do not reach for a converter that guesses, because it will guess wrong on identifiers and postal codes.
"9" + "1" -> "91"
Number("9") + Number("1") -> 10Only the comma is treated as a delimiter
Tab separated and semicolon separated files are not parsed. Semicolons are common in exports from European locale spreadsheets, where the comma is the decimal separator. Re-export as comma separated, or replace the delimiter first, being careful not to touch delimiters that appear inside quoted fields.
A duplicate header name silently wins
If two columns share a header, both write to the same object key and the rightmost column overwrites the others. JSON objects cannot hold two identical keys, so nothing warns you and one column disappears. Rename the columns in the source before converting.
How to Use
- Paste your CSV: Paste a spreadsheet export or database dump whose first line names the columns.
- Click Convert: Each subsequent row is converted to a JSON object using the header values as keys.
- Copy the JSON: Copy the JSON array output for use in your application, API, or database.
Key Features
- Automatic header detection from the first row
- Proper parsing of quoted fields with commas and newlines
- Handles escaped double quotes within fields
- Clean, formatted JSON output with 2-space indentation
Use Cases
- Importing spreadsheet data into a web application or API
- Converting CSV exports from databases into JSON for frontend use
- Transforming CSV log files into structured JSON for analysis
Frequently Asked Questions
Does the CSV need a header row?
Yes. The first row is treated as column headers and used as JSON object keys.
Are quoted fields supported?
Yes. Fields enclosed in double quotes are parsed correctly, including fields containing commas, line breaks, and doubled double quotes as escaped quotes.
Are all values treated as strings?
Yes, every value is emitted as a string. CSV carries no type information, and guessing would turn a postal code like 07030 into 7030 and a part number like 1E5 into 100000. Convert the columns you know are numeric in your own code.
What delimiter is supported?
The comma only. Tab and semicolon separated files are not parsed, which matters for exports from spreadsheets in locales that use the comma as a decimal separator. Re-export as comma separated first.
Can I convert CSV without a header row?
The first row is always treated as the header. If your CSV has no header, add column names as the first row before converting.
Does it handle Windows line endings and multi line fields?
Yes to both. Carriage return and line feed pairs, lone carriage returns, and lone line feeds all end a record, and a newline inside a quoted field stays part of the value because the whole document is scanned rather than split into lines first.
What happens if two columns have the same header?
Both map to the same object key and the rightmost one wins, because a JSON object cannot hold duplicate keys. No warning is shown, so rename the columns in the source file before converting.