What this CSV to JSON converter does
The converter reads comma-separated values, the format every spreadsheet and database can export, and turns them into JSON for an API, a configuration file, a test fixture or a script. By default the first row becomes the keys and every other row becomes an object. It detects the delimiter, follows the quoting rules of RFC 4180, reports malformed rows with line numbers, and can turn numbers and true/false into real JSON types.
How to convert CSV to JSON
- Paste CSV into the box, or open a .csv, .tsv or .txt file. The file is read on your device.
- Leave the delimiter on Auto-detect, or choose comma, semicolon, tab or pipe.
- Choose the JSON shape: an array of objects keyed by the header row, or an array of arrays that keeps every row, header included.
- Tick Convert numbers and true/false if you want typed values.
- Copy the JSON or download it as data.json.
CSV quoting rules
CSV looks simple until a value contains a comma. RFC 4180, the closest thing CSV has to a standard, sets these rules, and the converter follows them:
- Fields are separated by the delimiter and records by line breaks (CRLF or LF).
- A field that contains the delimiter, a double quote or a line break must be enclosed in double quotes.
- Inside a quoted field, a double quote is written as two double quotes.
- Spaces are part of the field.
a, bgives the values "a" and " b".
name,comment
"Smith, Jo","Said ""yes"" on the call"
"Lee","Line one
line two"
This sample has two records, not three. The second comment contains a real line break, which is allowed because it is inside quotes. The converter also removes a UTF-8 byte order mark at the start of the file, which Excel adds to CSV exports, and skips completely empty lines.
Type conversion
With the option ticked, a value becomes a number only if it is written as a plain JSON number: an optional minus, digits without leading zeros, an optional decimal part and exponent. So 42, -3.5 and 1e6 become numbers, while 01234, 1,000, $5 and 12 kg stay text. Integers above 9,007,199,254,740,991 also stay text, because JavaScript cannot store them exactly. true and false become booleans; empty fields stay empty strings.
Worked examples
A typical export
name,age,zip
"Smith, Jo",42,01234
With type conversion this becomes [{"name": "Smith, Jo", "age": 42, "zip": "01234"}]. The comma inside the quotes stays in the name, the age becomes a number and the ZIP code keeps its leading zero.
A European spreadsheet
A file exported with Excel set to German or French uses semicolons, because the comma is the decimal separator: a;b then 1,5;2. Auto-detect picks the semicolon and gives {"a": "1,5", "b": 2}. The value 1,5 stays text because JSON numbers use a decimal point.
A ragged file
If the header has 3 columns and line 7 has 4 fields, the extra value is kept under the key column_4 and a warning names the first line with a mismatch, so you can fix the source.
Tips and common mistakes
- Unclosed quotes swallow the rest of the file. If a quoted field never closes, the converter stops and names the line where it opened.
- Text after a closing quote is an error.
"x"yis invalid CSV. Write"x""y"if the value really contains a quote. - Keep identifiers as text. Phone numbers, ZIP codes and account numbers are labels, not quantities. Leave type conversion off if in doubt.
- Duplicate headers are renamed. Two columns called id become id and id_2, so no value is overwritten.
- Excel can change data before export. Long numbers may turn into scientific notation and dates into local formats. Format such columns as text in the spreadsheet first.
Limits and privacy
Input is limited to 10 MB. The output box shows up to 2 million characters, and the download always holds the complete JSON. Values are not trimmed, dates are not parsed and nested JSON is not built from dotted column names. The file never leaves your computer: it is read with the browser's File API and converted in the page.