CSV to JSON Converter
Published Updated
Paste CSV or TSV text, or upload a .csv, .tsv or .txt file, and get a JSON array: one object per row keyed by the header, or plain arrays when there is no header. Every value comes out as a string.
Strings in, strings out
The parser is Papa Parse 5.5.4 with its dynamicTyping option left at false, which the Papa Parse documentation describes as numbers and booleans "remaining strings". No types are guessed, and that has a benefit: a guess that turns 02134 into 2134 or rounds an 18-digit order number could not be undone later.
So the output is predictable. With a header row, each line becomes an object whose keys are the header names; without one, each line becomes an array. An empty cell becomes an empty string.
The same three lines, both ways
Input: name,age then Jane,32 then John,
| Setting | JSON output |
|---|---|
| First row contains headers (default) | [{"name": "Jane", "age": "32"}, {"name": "John", "age": ""}] |
| Headers off | [["name", "age"], ["Jane", "32"], ["John", ""]] |
Rows that do not match the header
Ragged files do not stop the conversion. What the parser does with each case:
| In the CSV | In the JSON |
|---|---|
| More values than headers | The surplus in an __parsed_extra array, plus a warning |
| Fewer values than headers | The missing keys are left out of that object, plus a warning |
| An empty line | Skipped |
| A line of spaces only | An object with just the first key, holding the spaces, plus a warning |
| A line of commas only | An object of empty strings |
| A quoted value with a line break | One string with \n inside |
The card counts rows that drew a warning: a,b, 1,2, an empty line, a line of spaces and 3,4 give 3 rows and 1 row had parse warnings. When Auto-detect cannot settle on a delimiter, the card also says no delimiter detected, read as comma-separated. A one-column list gets that note, and so did this file; both converted correctly.
Delimiters, quotes and byte order marks on real input
These inputs went through this page's converter in Google Chrome 157, Firefox 155 and Playwright's WebKit build (not the Safari app), pasted unless the row says uploaded. All three gave the same JSON and the same card:
| CSV | JSON and card |
|---|---|
a,b;c then 1,2;3 then 4,5;6 | Comma wins: keys a and b;c, first row "1" and "2;3" |
name price then Tea 1.50 (spaces between) | One key name price, plus no delimiter detected, read as comma-separated |
name,price with Semicolon chosen in the menu | One key name,price and no warning, so check the preview after forcing a delimiter |
| A quoted value holding a CRLF line break, in a file with CRLF line endings | "a\nb": a CRLF inside quotes becomes \n too |
id,note, then 1,"open, then 2,next (quote never closed) | 1 row, with note "open\n2,next", and 1 row had parse warnings |
1,say "hi" (quotes inside an unquoted value) | "say \"hi\"", kept as typed, no warning |
name , age then Ann , 30 | Keys "name " and " age", values "Ann " and " 30": nothing is trimmed |
,b then 1,2 (blank first header) | Key "" holding "1" |
007,1e5,true,,null,1.50,-0,0x1F under eight headers | All strings: "007", "1e5", "true", "", "null", "1.50", "-0", "0x1F" |
| Pasted text starting with U+FEFF, and an uploaded file starting with the bytes EF BB BF | First key name in both, with no hidden character in front |
| An uploaded file with é saved as the single Windows-1252 byte E9 | "Caf�": the replacement character U+FFFD |
Line endings are made uniform before parsing, so files that mix them still split into the right rows: a header and three rows separated by CRLF, LF and a lone CR gave 3 rows.
Converting CSV to JSON
Step 1
Add the data
Upload a CSV, TSV or TXT file, or paste rows into the text box. An uploaded file's text appears in the box, where it can be edited before converting.
Step 2
Check two settings
Leave First row contains headers on to get objects, and keep Auto-detect unless the result shows columns split in the wrong place.
Step 3
Convert and save
The JSON is indented with two spaces. Download it as yourfile.json (data.json for pasted text) or copy it; the card counts rows and parser warnings.
Encoding, quotes and line endings
- Files are decoded with Blob.text(), which always presumes UTF-8. A leading byte order mark is removed, so a file saved with one converts as it is.
- Quoting follows RFC 4180: a value in double quotes may hold commas and line breaks, and "" inside it stands for one quote mark.
- Windows, Mac and Unix line endings are all turned into one style before parsing, so a file mixing them does not merge two rows into one.
- Going the other way, JSON to CSV flattens objects back into columns, and JSON Formatter reindents or minifies the result.
CSV to JSON questions
Why are my numbers in quotes?
Because the parser runs with type conversion off, its default, so 32 is written as "32" and true as "true". That keeps leading zeros and long IDs intact. Convert the fields you need in your own code, where you know which columns are numeric.
Which delimiters does Auto-detect find?
Commas, tabs, pipes and semicolons, plus two rarely used ASCII separator characters. A file like name;price with values such as 1,50 is read as semicolon-separated, and 1,50 stays one value. Comma, Semicolon and Tab can also be forced from the menu.
What is __parsed_extra in my output?
A row had more values than the header has names. The extra values go into an array under the key __parsed_extra so nothing is thrown away, and the row is counted as a warning. Usually it points to an unquoted comma inside a value.
Why did é turn into a question mark symbol?
The file is read as UTF-8, and a CSV saved in an older Windows encoding stores é as a byte that is not valid UTF-8, so it shows as the replacement character. Save the file again as CSV UTF-8 and convert it once more.
What if two columns have the same name?
The parser renames the later ones: name, name, name becomes name, name_1 and name_2, so no value overwrites another. Rename the header in the CSV first if your code expects other keys.
Can I get arrays instead of objects?
Yes. Untick First row contains headers and each row becomes an array of strings, with the header row as the first array. That shape suits a script that reads columns by position.
Does a UTF-8 byte order mark end up in my first key?
No. An uploaded file that starts with the byte order mark bytes EF BB BF gave the first key name with nothing in front of it in Chrome 157, Firefox 155 and the WebKit build. Pasted text that starts with U+FEFF gave the same result.
Why does the card say no delimiter detected?
Papa Parse could not settle on a delimiter and fell back to commas; its own message is Unable to auto-detect delimiting character; defaulted to ','. For a one-column list that is correct, and the rows convert as they should. For a file separated by spaces, everything lands in one key, such as "name price", and the delimiter menu has no space option.
Are spaces around values trimmed?
No. name , age gave the keys "name " and " age", and Ann , 30 gave "Ann " and " 30". Remove the spaces in the CSV, or trim the strings in your own code.
What happens if a quote is never closed?
Everything after the opening quote, line breaks included, becomes one value. id,note then 1,"open then 2,next gave a single row whose note is "open\n2,next", and the card said 1 row had parse warnings.