Skip to main content
ponderloop

CSV to JSON Converter

Paste CSV and get JSON straight away, or switch direction and turn JSON back into CSV. The example CSV has 2 records and 4 columns; its first record becomes {"name":"Ada","city":"London","score":"92.5","note":"Likes \"maths\", code"}, with its quoted comma and doubled quotes kept intact (the second record’s note keeps the line break it contains). The delimiter (comma, semicolon, tab or pipe) is detected for you, the first row can be the header or not, and numbers, true/false and null can optionally be typed instead of kept as text. Errors show the exact line and column. Everything runs in your browser, so the data never leaves it.

Updated Runs in your browser: nothing you enter is uploadedHow this tool works

Direction
Stays in your browser

Replace the example: paste or type your data. The result updates as you type.

Your data is converted on this device and never uploaded. It is not saved either: reload the page and it is gone.

Options

Result

Converted 2 rows to an array of objects.

Counts

Rows
2
Columns
4
Delimiter
comma (detected)
Output size
215 bytes

What each CSV to JSON option does

The same CSV, “id,name,active,note ⏎ 007,Ada,true, ⏎ 12,"Grace, H.",FALSE,null”, with one option changed at a time (the semicolon row uses “id;name ⏎ 1;Ada, L.”).
OptionJSON resultEffect
Default[{"id":"007","name":"Ada","active":"true","note":""},{"id":"12","name":"Grace, H.","active":"FALSE","note":"null"}]Every value stays text, exactly as written, so nothing is guessed.
Infer types[{"id":"007","name":"Ada","active":true,"note":""},{"id":12,"name":"Grace, H.","active":false,"note":null}]Numbers, true/false and null become JSON values; 007 stays text because of its leading zeros; an empty cell stays "".
Infer types, empty as null[{"id":"007","name":"Ada","active":true,"note":null},{"id":12,"name":"Grace, H.","active":false,"note":null}]The same, with an empty cell written as null.
No header row[["id","name","active","note"],["007","Ada","true",""],["12","Grace, H.","FALSE","null"]]The first line is data too, and the result is an array of arrays.
Semicolon delimiter[{"id":"1","name":"Ada, L."}]Only the chosen character splits fields, so the comma stays inside the value.

How type inference reads a cell

Only when “Convert numbers, true/false and null” is on. A number is taken only if it reads back to the same digits.
CellJSON valueWhy
4242A whole number.
-3.14-3.14A decimal with a sign.
1e31000Exponent form is a valid JSON number.
truetruetrue and false match in any letter case, as spreadsheets write TRUE.
FALSEfalseSame rule, so Excel’s FALSE becomes false.
nullnullOnly the lowercase word null.
(empty)""An empty cell stays "" unless you choose null.
007"007"A leading zero marks an identifier (ZIP code, phone number), so it stays text.
+5"+5"JSON numbers cannot start with a plus sign.
12345678901234567890"12345678901234567890"More than 15 significant digits would lose precision as a number, so it stays text.
1,5"1,5"A decimal comma is not a JSON number.
yes"yes"Only true and false are booleans.

Repeated and empty headers

The header row “id,,id,id” gives every column a unique key.
InputJSON resultRule
id,,id,id ⏎ 1,2,3,4[{"id":"1","column_2":"2","id_2":"3","id_3":"4"}]An empty name becomes column_N (N is its position); a repeat gets _2, _3, … and a note tells you which were renamed.

How JSON values are written to CSV

Each value below is the only field of the only object in an array, converted with the default settings.
JSON valueCSV cellKind
"plain"plainString
"a, b""a, b"String with the delimiter
"say \"hi\"""say ""hi"""String with quotes
1.501.50Number (written as in the JSON)
truetrueBoolean
null(empty)Null
[1,2]"[1,2]"Nested array
{"city":"NYC"}"{""city"":""NYC""}"Nested object

How errors are reported

The line and column count characters from 1, as in a text editor.
InputPositionMessage
a,b ⏎ 1,"oops ⏎ 2,3line 2, column 3The quoted field starting here is never closed
a,b ⏎ "x"y,2line 2, column 4Unexpected “y” after the closing quote; expected a delimiter or line break
[{"a":1},{"a":}]line 1, column 15Unexpected “}”; expected a value
[1, 2,]line 1, column 7Unexpected “]”; expected a value
{"a" 1}line 1, column 6Unexpected “1”; expected “:” after the key

How to convert CSV to JSON

  1. Choose the direction. Leave “CSV to JSON” selected, or pick “JSON to CSV” to go the other way. The example switches to match until you type your own.
  2. Paste your data. Replace the example with your CSV. Quoted fields, commas and line breaks inside quotes, and Windows or Unix line endings are all read correctly.
  3. Check the options. The delimiter is detected from your data; pick one yourself if the guess is wrong. Untick “First row is a header” for an array of arrays, and tick the type option if you want numbers and booleans instead of text.
  4. Fix any error. If the data is malformed, the message gives the line and column with a caret under the spot, for example a quoted field that never closes.
  5. Copy or download. Copy the result to the clipboard or download it as a .json or .csv file. Nothing is uploaded.

Frequently asked questions

How do I convert a CSV file to JSON?
Open the CSV in a text editor, copy everything, paste it into the box above and copy or download the JSON. With the default settings the first row supplies the keys, so each later row becomes an object. Untick “First row is a header” to get an array of arrays instead.
Which CSV format does it read?
The format of RFC 4180: fields separated by a delimiter, records ended by CRLF or LF, fields wrapped in double quotes when they hold the delimiter, a quote or a line break, and a quote inside a quoted field written as two quotes. It also accepts a lone CR as a line break, skips blank lines, and tolerates a stray quote in the middle of an unquoted field.
How does the delimiter detection work?
The first 30 records are split with each of comma, tab, semicolon and pipe, ignoring anything inside quotes. The delimiter that gives the same number of fields (two or more) on the most records wins; a tie goes to comma, then tab, semicolon, pipe. Choose a delimiter yourself to override it, for instance for a one-column file.
Why are my numbers strings in the JSON?
By default every value stays text, because CSV has no types and guessing can corrupt data. Tick “Convert numbers, true/false and null” to get real numbers and booleans. Even then, values such as 007, +5 or a 20-digit ID stay text, because turning them into numbers would change them.
What happens to empty or repeated headers?
JSON objects cannot have two identical keys, so a repeated name gets _2, _3 and so on, and an empty one becomes column_N where N is its position. A note under the result lists every rename. Rows with more fields than the header get extra column_N keys, and short rows are filled with empty values.
How is JSON turned into CSV?
For an array of objects, the columns are every key found in any object, in the order first seen; an object without a key leaves that cell empty. For an array of arrays each inner array is a row. Strings are written as they are, numbers exactly as in your JSON, null as an empty cell, and nested objects or arrays as compact JSON text inside one quoted cell.
Are big numbers kept exact when converting JSON to CSV?
Yes. The JSON is read by a parser that keeps each number as the text you wrote, so 12345678901234567890 and 1.10 reach the CSV unchanged, where a normal JSON.parse would turn them into 12345678901234567000 and 1.1.
Will it handle a file with 100,000 rows?
Yes. Parsing is a single pass and the output is built in one go, so 100,000 rows take a fraction of a second on an ordinary computer. For very large pastes the result updates a moment after you stop typing so the page stays responsive.
Is my data uploaded anywhere?
No. The conversion runs in your browser and the text is never uploaded, stored or logged; it is gone when you close or reload the page. The only thing the site records, if you allow analytics, is that a button was used, never any of the data.

How it works

CSV is read with one pass over the text, following RFC 4180: a field that starts with a double quote runs to the next lone quote (two quotes in a row mean one literal quote), and may hold delimiters and line breaks; any other field ends at the next delimiter or line break. Records end at CRLF, LF or a lone CR, and a line with nothing on it is skipped. A quoted field that never closes, or text between a closing quote and the next delimiter, is an error reported at its line and column. To detect the delimiter, the first 30 records are read with each candidate and the one that yields the same count of two or more fields most often is chosen. With a header row, each later record becomes an object whose keys are the header names, made unique and non-empty. Type inference is off by default; when on, a cell becomes a number only if it matches the JSON number grammar of RFC 8259, has no leading zero and no more than 15 significant digits, true or false in any letter case becomes a boolean, the lowercase word null becomes null, and an empty cell becomes "" or null as chosen. JSON is read by a strict RFC 8259 parser that keeps numbers as written and keys in order. A top-level array of objects takes the union of all keys in first-seen order as columns; an array of arrays is written row by row, padded to the widest row; nested values are written as compact JSON text. A field is quoted when it contains the delimiter, a double quote, a line break, or a space or tab at either end (quotes inside are doubled); an empty value in a one-column file is written as "" so it does not look like a blank line. Rows are collected in an array and joined once, so the time grows in step with the size of the input.

Sources

All toolsHome & DIY calculators