StringToolsStringTools

CSV โ†” JSON Converter

Convert CSV to JSON and JSON to CSV instantly. Supports custom delimiters, headers, and type detection โ€” 100% browser-based.

Mitul MandankaFounder, Progragon Technolabs ยท 15+ years building software
Updated June 20268 min read

TL;DR

CSV looks trivial until a field contains a comma, a quote, or a line break. This converter is built on a parser that follows RFC 4180 โ€” so "Smith, John" stays one field, doubled quotes ("") decode to a single ", and newlines inside quoted cells don't split your rows. The first line becomes the JSON keys, numbers and booleans are typed automatically, and everything runs in your browser โ€” your file is never uploaded. If your import "works in Excel" but breaks elsewhere, the edge-case table below almost certainly explains why.

Why splitting on commas is not parsing CSV

The most common CSV bug in the world is line.split(","). It works on your sample data and silently corrupts real data the moment a value contains a comma, a quote, or a newline. CSV is not "values separated by commas" โ€” it is a small grammar with quoting rules, codified loosely in RFC 4180 (2005). Consider this single, perfectly valid row:

id,name,note
7,"Doe, Jane","Said ""hello"" and
then left"

A naive split produces five garbage columns. A correct parser produces exactly three fields: 7, Doe, Jane, and a note whose value is Said "hello" and followed by a real line break and then left. This tool produces the second result. Here is the JSON it returns:

[
  {
    "id": 7,
    "name": "Doe, Jane",
    "note": "Said \"hello\" and\nthen left"
  }
]

CSV pitfall reference: what breaks and how this tool handles it

These are the edge cases that quietly break spreadsheets, ETL jobs, and import scripts. The middle column is what a naive comma-splitter does; the right column is this converter's actual behavior (it uses an RFC 4180-aware parser with header detection and type inference).

PitfallNaive split(",")This converter
Comma inside a quoted field โ€” "Smith, John"Splits into two columns, shifting every later fieldKept as one field: Smith, John
Escaped quote โ€” doubled "" inside a quoted fieldLeaves stray quote characters in the valueDecoded to a single " per RFC 4180
Newline inside a quoted cell (multi-line address, log line)Treats it as a new record โ€” row count explodesKept inside the field as \n in the JSON string
UTF-8 BOM (EF BB BF) at the start of the fileFirst header key becomes ๏ปฟid โ€” lookups silently missBOM is stripped before parsing; first key is clean
Semicolon-delimited export (European Excel locale)Whole row lands in one columnSwitch the Delimiter dropdown to ;
Tab-separated values (TSV) copied from a spreadsheetNo commas, so nothing splitsPick Tab in the Delimiter dropdown
Windows line endings (\r\n)Trailing \r sticks to the last field of every rowBoth \r\n and \n are accepted
Numbers, booleans, empty cellsEverything is a string42 โ†’ number, true โ†’ boolean, empty โ†’ null
Leading zeros โ€” ZIP code 07030, SKU 00125Kept as a string (the one case split gets "right")Becomes the number 7030 โ€” see the warning below
Blank lines between recordsProduces empty/garbage rowsSkipped automatically

The leading-zeros row is the one place automatic typing can bite you. If your CSV has ZIP codes, phone numbers, or fixed-width IDs, wrap them in quotes and prefix with a non-numeric marker, or convert them after import โ€” see the FAQ.

Comma, semicolon, or tab? Detecting the real delimiter

"CSV" is a misnomer half the time. The actual separator depends on where the file came from, and the most common surprise is regional. In locales that use a comma as the decimal mark (most of continental Europe), Excel exports use a semicolon so that 1,5 stays one number. Files copied straight out of a spreadsheet cell range are usually tab-separated. Here is how to recognize each:

DelimiterWhere it comes fromTell-tale sign
Comma ,US/UK Excel, most APIs, pandas.to_csv()Decimals use a dot: 1.5
Semicolon ;European Excel (DE, FR, ES, IT, NL โ€ฆ)Decimals use a comma: 1,5
TabCopy-paste from a spreadsheet, .tsv filesColumns align in a monospace editor; no visible separator
Pipe |Database dumps, log exports, mainframe feedsValues may themselves contain commas freely

If your converted JSON comes back as a single key holding the entire row, you have the wrong delimiter selected. Switch the Delimiter dropdown above the editor and the output updates instantly.

Going the other way: what happens to nested JSON

CSV is flat; JSON is not. When you convert JSON โ†’ CSV, every object should be a flat key/value record. The tool reads an array of objects (a bare object is wrapped in a one-element array for you), takes the column headers from the keys of the first object, and quotes any value that contains the delimiter, a quote, or a newline โ€” round-tripping cleanly back to JSON. For predictable columns, make sure the first record contains every key your data uses.

Nested structures have no native CSV representation, so plan for them:

  • Nested values do not survive cleanly. A nested array is flattened into the cell (e.g. tags: ["a","b"] is written as a,b in one quoted column), and a nested object is coerced to [object Object] โ€” neither round-trips back to its original structure. Stringify nested fields yourself before converting if you need to recover them.
  • Mismatched keys: the header row is taken from the first object only. If a later record is missing one of those keys, its cell is left empty; if a later record has an extra key that the first record lacks, that value is dropped. Keep your records uniform โ€” or put a record with the full key set first.
  • If you need true flattening (address.city as its own column), flatten the JSON first; CSV has no concept of nesting.

CSV-to-JSON questions developers actually ask

My CSV has commas inside the values โ€” will the conversion break?

No, as long as those values are wrapped in double quotes, which is how every spreadsheet exports them. "Smith, John" is read as a single field. The RFC 4180-aware parser only treats a comma as a column separator when it is outside quotes. If your values contain commas but are not quoted, the file is malformed and no parser can recover the original columns โ€” re-export it from the source with quoting enabled.

Why did my ZIP code 07030 turn into 7030?

Automatic type detection sees a value that looks numeric and converts it, which strips the leading zero. This affects ZIP/postal codes, padded SKUs, account numbers, and any ID that is "digits that aren't really a number." The safe fix is to keep those columns as text at the source โ€” in Excel, format the column as Text before exporting; in pandas, pass dtype=str. If you only have the CSV, convert, then re-pad the affected field in your downstream code (e.g. String(zip).padStart(5, "0")).

My first column key looks like "๏ปฟid" with an invisible character. What is that?

That is a UTF-8 byte-order mark (BOM) โ€” the three bytes EF BB BF that Excel and some exporters prepend to the file. Naively parsed, it glues onto the first header so obj.id is undefined while obj["๏ปฟid"] works. This tool strips the BOM before parsing, so your first key is clean. If you hit a phantom-key bug elsewhere, the BOM is almost always the culprit.

Can a single CSV cell contain a line break?

Yes โ€” RFC 4180 explicitly allows newlines inside a quoted field, which is common in address and free-text columns. The parser keeps that line break inside the field and represents it as \n in the JSON string, instead of breaking your data into extra rows. This is exactly where split("\n")-based importers fall apart.

What is RFC 4180 and does it guarantee my file will parse anywhere?

RFC 4180 (2005) is the closest thing CSV has to a spec: comma separators, CRLF row endings, optional double-quoting, and doubled quotes ("") to escape a literal quote. It is informational, not a binding standard, so tools vary โ€” many accept semicolons, bare \n, and unquoted fields as extensions. This converter follows the quoting and escaping rules of RFC 4180 and additionally lets you pick the delimiter, which covers the vast majority of real-world files.

Is my CSV or JSON uploaded to a server?

No. The site is a static export with no backend, and all parsing and conversion run in your browser's JavaScript engine. You can confirm it in DevTools โ†’ Network: converting triggers zero outbound requests. That makes it safe for internal data exports that you would not want to paste into a hosted service โ€” though if a file is bound by strict compliance rules, prefer a fully offline tool.