CSV to JSON

A real CSV parser, so quoted commas and line breaks survive. Nothing leaves your browser.

CSV
JSON

Why splitting on commas is not enough

The obvious way to parse CSV is to split each line on the delimiter. It works until a field contains one, which in real data happens almost immediately: an address, a company name, a description with a comma in it. The quoting rules exist for exactly that case, and a field wrapped in quotes may contain the delimiter, a line break, or a quote of its own written as two quotes in a row.

The parser here reads character by character and tracks whether it is inside a quoted field, so "London, England" stays one value and a description spanning two lines stays one field. The symptom of getting this wrong is a column that appears shifted by one from a certain row onward, which is easy to miss and unpleasant to debug downstream.

CSVBecomes
a,bTwo fields
"a,b",cTwo fields; the first contains a comma
"say ""hi""",xTwo fields; the first is say "hi"
"line one
line two",x
Two fields; the first contains a line break

Type detection and leading zeros

With Detect numbers and booleans on, a value that looks like a number becomes one and true or false becomes a boolean, which is usually what an application consuming the JSON wants. The trap is identifiers: a product code of 007 or a postcode of 01234 becomes the number 7 or 1234 and the leading zeros are gone for good.

Values with a leading zero are therefore left as strings even when detection is on. Where any ambiguity remains, switching the option off keeps every value exactly as written.

Delimiters and ragged rows

Comma is the standard, but a spreadsheet exported in a country that writes decimals with a comma will usually be semicolon separated, and database exports are often tab separated. Detect counts the candidates in the first line and picks the most frequent, which is right nearly always; if the result comes out as a single column, the delimiter is the thing to check first.

Rows that do not match the header width are kept rather than dropped. A short row leaves the missing keys as empty strings, and a long row keeps the surplus under numbered keys such as column_4. The number of ragged rows is reported above the output, because a file with ragged rows usually has a real problem worth knowing about before the data goes anywhere.

How to use it

Paste your CSV and the JSON appears underneath as you type. Turn off First row is a header for a file with no header, in which case rows come out as arrays rather than objects. Minify output drops the indentation for a compact result.

Questions

Does it handle commas inside a field?

Yes. A quoted field may contain the delimiter, a line break or an escaped quote, and the parser tracks quote state character by character rather than splitting on the delimiter. Splitting is the single most common reason a converted address column comes out shifted by one.

Why did my leading zeros disappear?

Type detection turned a value such as 007 into the number 7. That is right for a quantity and wrong for a product code or a postcode, so the option can be switched off, in which case every value stays a string exactly as written.

What delimiter should I choose?

Whatever the file uses. Comma is standard, but exports from spreadsheets in countries that use a decimal comma are usually semicolon separated, and tab separated files are common from databases. Choosing the wrong one produces a single column, which is the obvious symptom.

What happens to a row with the wrong number of columns?

A short row leaves the missing keys empty and a long row keeps the extra values under numbered keys, rather than the row being dropped. The count of ragged rows is reported so you know the file has a problem instead of finding out later.

Is my data uploaded anywhere?

No. Parsing happens inside your browser and this tool has no backend, so the spreadsheet you paste is never transmitted, logged or stored.