CSV to JSON converter
Paste CSV or open a file and get clean JSON: an array of objects, an array of arrays, or objects keyed by an ID column. Quoted fields, commas and line breaks inside cells, and semicolon, tab or pipe files are handled. The second tab turns JSON back into CSV.
How the CSV is read
CSV looks simple until a cell contains a comma. The converter follows RFC 4180, the closest thing CSV has to a standard, and the habits of spreadsheet exports:
- Each line is a row and the separator splits it into fields.
- A field wrapped in double quotes can contain the separator and even line breaks:
"Okafor, Ada"is one field. - Inside a quoted field, two double quotes stand for one:
"Prefers ""email"""becomesPrefers "email". - Windows (CRLF), Unix (LF) and old Mac (CR) line endings all work, and the byte order mark that Excel puts at the start of UTF-8 files is removed, so your first column name does not start with an invisible character.
- The separator is detected by trying comma, semicolon, tab and pipe on the first 20 rows, outside quotes, and picking the one that gives the same number of columns on every row. Many European versions of Excel save with semicolons, because the comma is their decimal mark. You can always choose the separator yourself.
Messy files are read the way spreadsheets read them: a stray quote in the middle of an unquoted field is kept as text, with a note. A quote that is opened and never closed is an error naming the line, because guessing would silently merge rows.
Worked example
The sample in the box has a header and three rows. With the default options the first row becomes:
{ "id": 1, "name": "Okafor, Ada", "city": "Lagos", "joined": "2024-03-01", "active": true, "notes": "Prefers \"email\"" }
The comma inside the quoted name did not split the field, the doubled quotes became one quote (written \" in JSON), 1 became a number and true a boolean. Ben's empty notes cell becomes null. Chen's city keeps its line break as "New\nYork", and Zip 02134 stays text. Dates stay as text too, because JSON has no date type.
The output options
- Array of objects uses the header as keys, which is what most APIs and JavaScript code expect. Duplicate header names get
_2,_3added and blank ones becomecolumn_1and so on, so no column is lost. - Array of arrays keeps every row, header included, as a plain list. It is the smallest output and keeps column order exactly.
- Object keyed by a column turns
id(or the column you name) into the keys:{ "1": { "name": … }, "2": { … } }. Handy for lookups. If an ID repeats, the later row wins and you get a note. - Type guessing turns plain numbers such as 42, -3.5 and 1e3 into numbers. Values with leading zeros (007, ZIP codes), thousands separators, a plus sign, or more digits than JavaScript can hold exactly (long order IDs) stay text, so nothing is changed by accident. Untick it to keep every value as text.
- Nested objects turn headers such as
address.cityandaddress.zipinto{ "address": { "city": …, "zip": … } }. A dotted header stays flat if a plainaddresscolumn also exists, so no value is overwritten.
JSON back to CSV
The second tab takes an array of objects and makes one column per key, in the order keys first appear, so objects with different keys still line up. Nested objects become dotted columns (dims.w), and arrays are written as JSON text in one cell. Fields that contain the separator, a quote, a line break, or spaces at either end are quoted. In the sample, Desk lamp, brass is written as "Desk lamp, brass" and Shade "linen" as "Shade ""linen""".
A spreadsheet runs any cell that starts with = as a formula, which matters when the data came from strangers (a form, a scraped page). The formula option puts an apostrophe in front of such text so it shows as text. Leave it off for data you will load into another program, since the apostrophe becomes part of the value. To check or tidy JSON before converting, use the JSON formatter.
FAQ
Is my file uploaded?
No. The file is read and converted by JavaScript in this page, on your device. That also means large files are limited by your browser's memory rather than an upload limit; files up to 50 MB can be opened.
Why are my accents or symbols garbled?
The file is read as UTF-8. Older Excel versions on Windows can save CSV in a regional encoding instead. In Excel choose File > Save As > "CSV UTF-8 (Comma delimited)" and open the new file.
Why did a number with leading zeros stay text?
Turning 02134 into the number 2134 would change the value, which breaks ZIP codes, phone numbers and product codes. The same goes for 1,000 and very long IDs. Only plain numbers that survive the round trip unchanged become JSON numbers.
My rows have different numbers of fields. What happens?
Missing fields become null and extra fields get keys like column_7, and the result notes how many rows were uneven. Uneven rows often mean the separator was detected wrongly or a quote is missing, so check the preview table.
Can I convert an Excel .xlsx file?
Not directly: an .xlsx workbook is a zipped bundle of XML, not text. Open it in Excel, Google Sheets or LibreOffice and save or download the sheet as CSV, then open that file here.
Which line endings does the CSV output use?
CRLF (Windows style), which RFC 4180 specifies and every spreadsheet and CSV library reads. The download can start with a byte order mark so Excel recognises UTF-8; untick that option if another program expects plain UTF-8.