CSV to JSON Converter
Convert CSV to JSON in your browser, with control over type inference so leading zeros survive. Covers the Excel BOM and semicolon-delimiter traps.
What CSV to JSON Converter Does
CSV looks simple and is not. There is no binding standard: RFC 4180 is an informational memo describing common practice, and real files violate it routinely. Converting to JSON forces every ambiguity in a CSV file to be resolved, which is why conversion is where data quietly breaks.
The two hard problems are quoting and typing. Quoting decides where a field ends when the field itself contains a comma, a quote or a newline. Typing decides whether the text 007 becomes the string "007" or the number 7, and if it is a product code, that conversion has destroyed it.
This converter parses quoted fields, including ones that contain commas, doubled quotes and line breaks, strips a UTF-8 byte-order mark, accepts comma, semicolon or tab delimiters, and lets you switch number detection off. The sections below cover what to check before trusting any CSV conversion, including this one.
How to Use CSV to JSON Converter
- Paste your CSV text or JSON array in the input box
- Choose whether to convert CSV to JSON or JSON to CSV
- Click Convert to generate the formatted output
- Click Copy Output to paste into your code editor or workflow
How CSV to JSON Converter Works
CSV to JSON, field by field
read characters left to right → a " at the start of a field opens a quoted field (inside it, "" is a literal quote and delimiters or line breaks are data) → first row = keys → each later row = one object
- quoted field
- RFC 4180 section 2: a field wrapped in double quotes may contain the delimiter, a line break, or a quote written twice (""). An unclosed quote is reported as an error rather than guessed at.
- delimiter
- Comma by default; semicolon or tab when selected. Semicolons are what Excel writes in locales that use the comma as the decimal separator.
- number detection
- When on, a field becomes a JSON number only if it is a plain decimal with no leading zero and no exponent, and it survives conversion without losing digits. 02134, 007, 1e5, +5, 1,000 and 20-digit IDs stay strings.
- JSON to CSV
- The header is every key found in any object, in first-seen order. A value containing the delimiter, a quote or a line break is quoted, with inner quotes doubled.
Worked example
Three lines of CSV: name,zip,note / "Smith, Jr.",02134,"said ""hi""" / Ana Ruiz,94105,
- Header row gives the keys name, zip and note
- "Smith, Jr." is quoted, so its comma is data, not a field break
- "said ""hi""" is quoted; each "" becomes one literal quote: said "hi"
- 02134 has a leading zero, so it stays the string "02134"; 94105 is a plain number and becomes 94105
- The empty last field of row 3 becomes an empty string
Result: [{"name":"Smith, Jr.","zip":"02134","note":"said \"hi\""},{"name":"Ana Ruiz","zip":94105,"note":""}]. The two ZIP codes now have different types, which is why number detection should be off for an ID column.
Type Inference Hazards
What naive numeric conversion does to values that look like numbers but are not. Verified against the JavaScript engine.
| CSV value | Becomes | Why it matters |
|---|---|---|
| 007 | 7 | Product codes, US ZIP codes and account numbers lose leading zeros permanently |
| 0123 | 123 | Same problem; the original cannot be recovered |
| 1e5 | 100000 | A gene name, part number or ID read as scientific notation |
| +1 | 1 | A phone country code becomes the number one |
| 1,234 | NaN or "1,234" | Thousands separators are not numbers |
| TRUE | string or boolean | Depends entirely on the parser |
| 2026-09-06 | string | JSON has no date type; it stays text |
Quoting Rules (RFC 4180)
| Situation | Correct CSV | Resulting value |
|---|---|---|
| Field contains a comma | "Smith, John" | Smith, John |
| Field contains a quote | "He said ""hi""" | He said "hi" |
| Field contains a newline | "line one⏎line two" | A single field with a line break |
| Empty field | a,,c | The middle value is an empty string |
| Field with leading spaces | " padded" | Spaces inside quotes are significant |
Source: RFC 4180 — Common Format and MIME Type for CSV Files
Why a File That Looks Fine Fails
| Cause | Symptom | Fix |
|---|---|---|
| UTF-8 BOM from Excel | First column name has an invisible prefix, so row.name is undefined | Strip the BOM before parsing the header |
| Semicolon delimiter | Every row becomes one field | European Excel uses ; when the decimal separator is a comma |
| CRLF vs LF | Trailing \r on the last field of every row | Normalize line endings first |
| Duplicate column names | One column silently overwrites the other | JSON object keys must be unique — rename first |
| Ragged rows | Some objects missing keys, or extra values dropped | Rows must have the same field count as the header |
| Mixed encodings | Accented characters become mojibake | Confirm the file is UTF-8, not Latin-1 |
How to Read Your Result
The BOM is the bug you cannot see
Excel writes a UTF-8 byte order mark at the start of the file. A naive parser makes the first header "\uFEFFname" rather than "name", so every lookup on that column returns undefined while the data looks perfect in the output. This is one of the most time-consuming CSV bugs precisely because the character is invisible. Strip a leading U+FEFF before splitting the header row.
Turn type inference off for identifiers
Any column that is an identifier rather than a quantity (SKU, ZIP code, phone number, account reference) should stay a string. The damage from converting "007" to 7 is irreversible once the original file is gone, and it usually surfaces weeks later when a join stops matching.
Semicolons are not a broken file
In locales where the comma is the decimal separator, Excel exports semicolon-delimited files and still calls them CSV. If every row parses as a single field, check the delimiter before concluding the file is corrupt.
JSON arrays versus newline-delimited JSON
A single JSON array is convenient for small data and awkward for large data, because the whole document must be parsed at once. NDJSON, with one JSON object per line, streams and appends, which is why log pipelines and data warehouses prefer it. For a large export, NDJSON is usually the better target.
Limitations & Accuracy Notes
- Conversion runs in your browser, so file size is bounded by available memory. Multi-hundred-megabyte files need a streaming parser rather than a web page.
- CSV has no standard for representing null. An empty field could mean empty string, null or missing, and the converter has to pick one, so check which convention your consumer expects.
- Column order is preserved in the output, but JSON objects are formally unordered and a consumer is free to ignore it.
- Nested JSON cannot be inferred from a flat CSV without a naming convention for the headers. This converter produces flat objects.
- Very large integers beyond ±(2^53 − 1) lose precision if converted to numbers, exactly as they do anywhere else in JSON. Keep long IDs as strings.
Frequently Asked Questions
How does CSV to JSON conversion work?
The tool parses the first CSV row as object keys/headers and creates a JSON array of structured objects corresponding to each subsequent data row.
Is my data private and secure?
Yes, all conversion runs 100% in your browser using client-side JavaScript. No data is sent over the network.
How does the converter handle commas inside a CSV field?
Standard CSV wraps any field containing a comma in double quotes. A compliant parser recognizes and preserves quoted fields as a single value instead of splitting on the comma inside them.
What happens if my CSV rows have missing values?
Empty cells convert to empty strings in the resulting JSON, keeping every row’s object structure consistent, so no row is dropped or reshaped because of a missing field.
How are commas inside a field handled?
A field containing a comma has to be wrapped in double quotes in the source CSV, as the format requires. A quoted field is read as a single value regardless of what is inside it, including commas and line breaks.
What happens to the header row?
It becomes the object keys, so each subsequent row converts to one object. If your file has no header row, the first data row will be consumed as one, which is usually obvious in the output.
Are numbers converted to JSON numbers or left as strings?
CSV has no type information, so everything in the file is text. Any conversion to numbers or booleans is a guess made by the parser, and it is worth checking the output for fields like postal codes or product IDs with leading zeros, which lose them if treated as numbers.
Is my file uploaded?
No. The conversion runs in your browser, which matters because CSV exports are so often customer lists, transaction records or other data you would not want to hand to a third party.
Does it handle semicolon-separated files?
Semicolons are common in locales where the comma is the decimal separator, and a file using them will not parse as comma-separated. Replacing the delimiter before converting is the simplest fix.
Why do some rows have missing keys?
Because those rows had fewer fields than the header row. A ragged CSV, with rows of differing length, is malformed, and the usual cause is an unescaped comma or quote somewhere earlier in the file.
References & Further Reading
- RFC 4180 — Common Format and MIME Type for Comma-Separated Values (CSV) Files — The informational memo describing common CSV practice, including the quoting rules
- RFC 8259 — The JSON Data Interchange Format — The target format, and why it has no date or integer type