# CSV to JSON Converter - Header Row, Delimiter Detection, Quoted Fields

Page: https://hirantha.me/tools/csv-to-json-converter
Part of: Hirantha Sandaruwan Lakshan free tools (https://hirantha.me/tools)
Updated: 2026-10-15

Convert CSV to JSON in your browser. Handles quoted fields and line breaks per RFC 4180, detects the delimiter, and keeps values like 007 as text.

This is a free tool that runs in the browser: open the page to use it. File tools process files on the visitor's own device; files are never uploaded or stored. No account, sign-up, payment or watermark.

Paste CSV, or open a file, and get JSON as a list of objects (using the first row as the names) or as a list of lists. The reader follows RFC 4180: quoted values can hold commas, line breaks and doubled quotes, and files from Excel that use semicolons or tabs are detected automatically. Numbers stay text unless you ask for conversion, so a code such as 007 is never changed. Everything runs in your browser.

The reader is a small state machine written for this tool, not a library. It goes through the text one record at a time. A value that starts with a double quote runs to the next lone double quote, so it can contain the delimiter, line breaks and two double quotes in a row, which stand for one quote. Records end at CRLF, LF or a lone CR. A byte order mark at the start of the file is dropped, and one line break at the end does not create an empty row. Where real files break the rules the reader is forgiving and tells you: a quote inside an unquoted value is kept as text, and text after a closing quote is kept and added to the value.

Detect looks at the first records and picks the delimiter (comma, semicolon, tab or pipe) that splits them into the same number of columns most often, with at least two columns. That is how a file such as Product;Price;In stock, with a decimal comma in 850,50, is read correctly. You can also choose the delimiter yourself. With the header option on, the first row gives the keys. An empty name becomes column3 and so on, and a repeated name gets _2, _3 added. A row with fewer values than the header is padded with empty values, and a row with more gets extra keys called column4 and so on. If you would rather stop, choose to report the first uneven row as an error with its row and line number.

Conversion is off by default, because guessing types loses data. When it is on, only text written the way JSON writes numbers is converted: an optional minus sign, digits with no leading zero, an optional decimal part and an optional exponent. So 42, -3.5 and 1e3 become numbers, but 007, +5, .5, 1,234 and 0x1F stay text. A number with more than 15 significant digits also stays text, because a JSON number is a 64 bit float and would lose its last digits (a 16 digit card or account number is the usual victim). The number is written exactly as it appears, so 10.50 stays 10.50. The words true and false in any case become booleans and null becomes null. A separate option turns empty cells into null. Dates are never converted.

If a quoted value is never closed, the tool does not guess. It reports the row, the line and the column where the quote was opened, because everything after an open quote would otherwise be swallowed into one value. Empty lines are skipped, and they still count in row numbers so the numbers match what a spreadsheet shows. The JSON text is written by the tool itself, in the same order as the CSV columns, so a header such as 2024 stays where it is instead of moving to the front the way a JavaScript object would, and a header named __proto__ is an ordinary key. Choose 2 or 4 spaces, a tab or minified output.

How text is converted when conversion is switched on:
| Text in the CSV | Becomes in the JSON | Why |
| --- | --- | --- |
| 42 | 42 | A plain whole number |
| -3.50 | -3.50 | A plain decimal number, written exactly as it appears |
| 1e3 | 1e3 | A number with an exponent |
| 007 | "007" | A leading zero marks a code, not a number |
| +5 | "+5" | JSON numbers have no plus sign |
| 1,234 | "1,234" | A thousands separator is not JSON |
| 12345678901234567 | "12345678901234567" | More than 15 digits would lose precision as a number |
| TRUE | true | true and false in any case are booleans |
| null | null | null in any case is null |
| (empty cell) | "" | An empty string, or null when "Empty cells become null" is on |

Q: How does the tool choose the delimiter?
A: It reads the first records with each of comma, semicolon, tab and pipe, and picks the one that splits them into the same number of columns most often (at least two). If you disagree, choose the delimiter yourself. A file with one column has no delimiter, and then a comma is assumed.

Q: What happens when a value contains a comma or a line break?
A: If the value is in double quotes, the comma or line break is part of the value. That is the RFC 4180 rule. Two double quotes in a row inside quotes stand for one quote. If the quotes are missing, the comma ends the value, because there is no way to tell it apart.

Q: Why are my numbers strings in the JSON?
A: Conversion is off by default, so every value is text. Switch on Convert numbers, true/false and null to get real numbers. Even then, text like 007, +5 or a number with more than 15 digits stays text, because converting it would change or lose data.

Q: What happens to rows with a different number of values?
A: By default a short row is padded with empty values and a long row gets extra keys named column4, column5 and so on, and the tool tells you how many rows were affected. Choose to report as an error and the conversion stops at the first uneven row and names its row and line.

Q: Can I convert an Excel .xlsx file?
A: Not directly. In Excel use Save As and choose CSV, in the UTF-8 version if your Excel offers it, then open that file here. Excel on a computer with a comma as the decimal mark often saves with semicolons, which the tool detects.

Q: How are accented letters and other alphabets handled?
A: The Open a file button reads the file as UTF-8. If the bytes are not valid UTF-8, it reads the file as Windows-1252, which is what Excel on Windows often writes, and tells you. A byte order mark at the start is removed. Text you paste is already text, so no decoding applies.

Q: Does it keep the order of the columns?
A: Yes. The JSON is written in CSV column order, including headers that are whole numbers, which a JavaScript object would move to the front.

Q: Is my CSV uploaded anywhere?
A: No. The file is read and converted by JavaScript in your browser tab, and nothing is sent to a server.

Q: How big a file can I convert?
A: Up to 25 million characters, which is about 25 MB of plain text. The Open a file button reads files up to 40 MB. The JSON box shows the first 200,000 characters of a long result, and Copy and Download use the whole result.

Sources: RFC 4180: Common Format and MIME Type for CSV Files (https://www.rfc-editor.org/rfc/rfc4180); RFC 8259: The JSON Data Interchange Format (https://www.rfc-editor.org/rfc/rfc8259); Microsoft Support: Import or export text (.txt or .csv) files (https://support.microsoft.com/en-us/office/import-or-export-text-txt-or-csv-files-5250ac4c-663c-47ce-937b-339e391393ba)

Related tools:

- [JSON to CSV converter](https://hirantha.me/tools/json-to-csv-converter.md): Convert JSON to CSV in your browser. Flattens nested objects, joins or numbers arrays, quotes fields per RFC 4180 and downloads a file Excel can open.
- [JSON formatter & validator](https://hirantha.me/tools/json-formatter.md): Pretty-print, minify, and validate JSON with clear error locations.
- [Remove duplicate lines](https://hirantha.me/tools/remove-duplicate-lines.md): Remove duplicate lines from a list and see how many were removed. Keep the first or last copy, ignore case or spaces, or show only the repeated or only the unique lines.
- [Sort lines (A to Z, numeric, shuffle)](https://hirantha.me/tools/sort-lines-tool.md): Sort lines A to Z, Z to A, by number or by length, or reverse and shuffle them. Natural number order, case options and language-aware sorting, live as you type.
