ToolBench

Convert

Convert CSV to JSON

Naive splitting on commas breaks the moment a field contains one — an address, a product name, a sentence. This parser follows the quoting rules properly, so `"Smith, John"` stays a single value.

JSON appears here.

How to use it

  1. Paste CSV or TSV into the box; the delimiter is detected from the first line.
  2. Keep “First row is the header” ticked to use it as object keys.
  3. Tick “Convert numbers” if numeric fields should be JSON numbers rather than strings.
  4. Copy the resulting array into your code or fixture file.

CSV has no official standard

There is no specification with the force of law behind CSV. RFC 4180 describes the common convention — comma separator, double quotes around fields containing separators, doubled quotes for a literal quote — but plenty of software deviates. Excel in a European locale writes semicolons by default, because the comma is the decimal separator there. That single fact breaks more import pipelines than any other.

Encoding and the byte-order mark

A file exported from Excel on Windows often begins with a UTF-8 byte-order mark. It is invisible in a text editor but becomes part of the first column name, so your code looks for “name” and finds “name”. If the first key of your converted JSON looks like it has a stray character, that is almost always the cause — strip the BOM before parsing. For Chinese or accented text, confirm the file is UTF-8 rather than a legacy code page, which will mangle every non-ASCII character.

What Excel actually exports

Three things break the naive conversion. First, Excel on Windows writes a UTF-8 byte-order mark, which becomes part of the first column name — so your key is \ufeffid, not id. Second, a machine with a European locale exports semicolon-delimited files, because the comma is the decimal separator. Third, long numeric IDs get converted to scientific notation and lose their last digits before you ever see the file.

Check all three before writing the parser: open the file in a text editor, look at the first three bytes, and look at one data row to confirm the delimiter.

Frequently asked questions

Are quotes and commas inside fields supported?

Yes. A field wrapped in double quotes may contain commas, tabs and newlines. A literal quote inside such a field is written as two quotes, which is the RFC 4180 convention.

What happens to duplicate column names?

Later values overwrite earlier ones, because a JavaScript object cannot hold two identical keys. Rename the headers if that matters.

Why keep ID columns as strings?

Leading zeros disappear the moment a value becomes a number — 007 becomes 7. Leave the numeric conversion off unless the field is genuinely arithmetic.

Is there a size limit?

Only your browser's memory. A few megabytes of CSV converts in well under a second.

What happens to duplicate column names?

The later column overwrites the earlier one in the object, silently. Rename duplicates in the source before converting.

Can it handle nested JSON?

No. CSV is flat by definition; dotted headers like user.name stay flat strings here rather than becoming nested objects.