CSV to JSON Converter
Convert CSV to JSON, or JSON back to CSV, right in your browser. Paste text or open a file: nothing is uploaded and the data never leaves your device. The reader handles quoted fields and line breaks inside fields, detects the delimiter and can turn numbers and booleans into real JSON values.
Input
Options
Accepts an array of objects, an array of arrays, or NDJSON (one object per line). Nested objects and arrays are written as JSON text in the cell.
Output
—
The conversion runs locally in your browser. Your data is not uploaded or sent to a server.
Preview
—
The preview shows the first 100 rows. Numbers and
booleans are set in a monospace font and null in italics. A row marked with
⚠ has a different number of fields than the header: its missing fields become
null and its extra fields get the keys _extra1,
_extra2, …
The preview shows the first 100 rows of the
table that is written as CSV. Numbers and booleans are set in a monospace font; an
empty cell stands for null or a missing key. In an array of arrays, a
row marked with ⚠ has a different number of fields than the first row.
How to use the CSV to JSON converter
- Choose the direction: CSV → JSON or JSON → CSV.
- Paste your data into the input box, or open a local file with the file button or by
dropping it onto the box. A file ending in
.json,.ndjsonor.jsonlswitches the direction to JSON → CSV. - Leave the delimiter on Auto-detect, or pick comma, semicolon, tab or pipe yourself. The status line names the delimiter that was used.
- Set the options: whether the first row is a header, whether numbers and booleans are inferred, what an empty field becomes, the output format and the indentation.
- Read the status line, the warnings and the preview table, then press Copy or Download.
The result updates while you type. Above about 1 MB of input, press Convert instead; the boxes then show only part of the data, but Copy and Download give the complete result. Files are read as UTF-8 text.
How it works
The CSV reader follows RFC 4180, the document that describes the common CSV format:
- Fields are separated by the delimiter and records by a line break (CRLF, LF or CR). A line break after the last record is optional.
- A field may be enclosed in double quotes. Inside the quotes, delimiters and line breaks
are ordinary text, and a quote character is written twice:
"". - A quote in the middle of an unquoted field is kept as it is.
- A quoted field that is never closed, or text right after a closing quote, stops the conversion with a message that names the line.
Delimiter detection. The tool counts commas, semicolons, tabs and pipes outside quotes in the first 30 non-empty records. The character that appears the same number of times in the most records wins. A tie goes to the higher count, then to the order comma, semicolon, tab, pipe.
Type inference. A field becomes a JSON number only when it is written the way JSON writes numbers (an optional minus sign, digits without a leading zero, an optional fraction and exponent) and turning it into a number and back gives the same value. Everything else stays text:
| Field text | JSON value | Reason |
|---|---|---|
42, -0.5, 1.50 | 42, -0.5, 1.5 | plain numbers |
1e3 | 1000 | exponent notation |
007, +5 | "007", "+5" | leading zero, plus sign |
1,5, 0x1F, 555-0100 | text | not JSON numbers |
12345678901234567890 | text | whole numbers outside ±9,007,199,254,740,991 (253 − 1) would be rounded |
true, FALSE | true, false | booleans, in any letter case |
| empty field | null or "" | your choice |
A decimal with more digits than a number can hold exactly also stays text. Quotes do not
change the type unless you tick Keep quoted fields as text; then a quoted
"42" stays text and a quoted empty field stays an empty string. With
inference off, every value is text.
Header names become the object keys. An empty name becomes
fieldN, where N is the column number, and a repeated name gets a suffix:
name, name_2, name_3. Both cases are reported.
Without a header row the keys are field1, field2 and so on.
Rows with the wrong number of fields are listed with their line number
and marked in the preview. Missing fields become null; extra fields get the
keys _extra1, _extra2, … In array-of-arrays output a row
keeps exactly the fields it has.
Examples
Example 1 — quoted fields. Press Load example in CSV → JSON mode:
id,name,joined,active,score,notes 007,"Smith, John",2024-03-15,true,91.5,"Said ""hello""" 8,Anna Lee,2023-11-02,FALSE,,"Line 1 Line 2"
The status line reports 2 rows, 6 columns and a comma delimiter. The ID with a leading
zero stays text and the empty score becomes null:
[
{
"id": "007",
"name": "Smith, John",
"joined": "2024-03-15",
"active": true,
"score": 91.5,
"notes": "Said \"hello\""
},
{
"id": 8,
"name": "Anna Lee",
"joined": "2023-11-02",
"active": false,
"score": null,
"notes": "Line 1\nLine 2"
}
]
Example 2 — semicolons. The three lines
id;price;ok, 007;1.50;true and 8;;false are
detected as semicolon-separated. With minified output the result is
[{"id":"007","price":1.5,"ok":true},{"id":8,"price":null,"ok":false}].
Example 3 — uneven rows. The lines a,b,
1,2,3 and 4 give two warnings, “Line 2: 3 fields, expected
2.” and “Line 3: 1 field, expected 2.”, and the minified output
[{"a":1,"b":2,"_extra1":3},{"a":4,"b":null}].
Example 4 — JSON to CSV. The input
[{"a":1,"b":"x,y"},{"a":2,"c":"he said \"hi\""}] has three different keys, so
the CSV gets three columns:
a,b,c 1,"x,y", 2,,"he said ""hi"""
Array of objects, array of arrays or NDJSON?
- Array of objects is what most programs and web APIs expect: one object per row, with the header names as keys. It repeats every key in every row, so it is the largest of the three.
- Array of arrays keeps the table shape. The header row comes first, as text, and each data row is one array. It is compact and keeps the original header names, even duplicates.
- NDJSON (newline-delimited JSON, also called JSON Lines) puts one object on each line, with no surrounding brackets. A program can read it line by line without loading the whole file, which suits logs and bulk imports.
JSON to CSV: what happens to nested data
For an array of objects the columns are all keys that occur in any object, in the order
in which they first appear; an object that lacks a key gets an empty field. An array of arrays is
written row by row without a header line. null becomes an empty field. A
nested object or array is not spread over several columns: it is written as JSON text in
one cell.
A field is put in double quotes when it contains the delimiter, a quote, a line break, or a space at its start or end, and every quote inside it is doubled. Records end with CRLF, as RFC 4180 specifies, or with LF if you choose it.
Frequently asked questions
Why is a value that looks like a number in quotes?
Because it would not survive as a JSON number. Leading zeros (ZIP codes, IDs), a plus sign, a decimal comma, thousands separators and whole numbers beyond ±9,007,199,254,740,991 are kept as text so that no digit is lost. To keep every value as text, turn type inference off.
How do I convert a semicolon- or tab-separated file?
Open it as it is. Auto-detect recognises semicolons, tabs and pipes as well as commas,
and the status line shows which one it chose. A decimal comma, as in 1,5, is
not a JSON number, so such values stay text.
Why do I get a warning about the number of fields?
A record has more or fewer fields than the header. The usual causes are a delimiter or a line break inside a field that is not quoted. Check the line named in the warning.
How large a file can it convert?
Files up to 50 MB are accepted. In our test a 5 MB file with 50,000 rows converted in about one second on a desktop computer. The practical limit is the memory of your device, because the input and the output are both held in the browser.
Is my data uploaded anywhere?
No. The file is read and converted by your browser, and the page sends nothing to a server. Your settings and the input text (only up to about 100 KB) are saved in this browser's local storage so that they survive a reload; Clear also empties the saved copy of the text you see.
Related tools
- JSON Formatter — format, validate and minify JSON text.
- List Compare — find the items two lists share and the ones that differ.
- Regex Tester — try a regular expression against sample text.
- Histogram Maker — turn a column of numbers into a histogram.