On-device AI — professional-grade, fully private.

Documents

How to Convert CSV to JSON (Keys, Types, Delimiters and Encoding)

Turn a CSV file into JSON in four steps. The header row becomes keys, numbers stay numbers, leading zeros survive, and Excel encodings are handled.

Updated November 7, 20268 min read

To convert a CSV file to JSON, drop it into the CSV to JSON converter, leave "First row is the header" on, and press Convert. The first row becomes the keys and every other row becomes an object, so you get an array like [{"id": 1, "name": "Ada"}]. Then copy the text or download a .json file. The part that decides whether the result is usable is not the conversion itself but four details: how the delimiter is detected, how the file's encoding is read, what happens to numbers and blanks, and which output shape you choose. This guide covers each of them.

What the conversion does

A CSV file is plain text: one row per line, cells separated by a delimiter, and the first line usually naming the columns. JSON is structured text with keys, values and types. Converting means reading each line, splitting it into cells, pairing every cell with its column name and writing the pairs out as JSON. With the default settings, a file with the header id,name,active and the row 7,Ada,TRUE becomes an object with the keys id, name and active, where 7 is a number and TRUE is a real true.

If you only want to look at a file first, open it in the CSV viewer. If you are not sure whether JSON is even the right format for your data, JSON vs CSV vs XML compares them.

Convert a CSV file to JSON, step by step

1

Add the file

Drop a .csv, .tsv, .txt or .psv file on the page, or choose Browse files. The delimiter, quote character and encoding are detected and shown under "Reading the file", so you can see what was chosen.

2

Pick the output shape

Leave "Output shape" on Array of objects for an API or a web app. The other four shapes are explained below.

3

Check the preview

The preview shows the first 200 records and updates as you change any setting. Look at the keys, the numbers and the blank cells. If letters look wrong or columns are merged, fix Encoding or Delimiter now.

4

Convert and export

Press Convert to JSON, then use Copy JSON or Download JSON. It all runs on your device, not our servers.

Every output shape and option is free. Free: one file at a time, up to 25 MB. Pro: batches of up to 50 files, one ZIP download and combining files into one document.

Convert CSV to JSON

The header row becomes the keys

With "First row is the header" on, the first line supplies the property names. With it off, the first line is treated as data and the columns are named column_1, column_2 and so on, so nothing is lost. Turn it off for files that start straight with data, such as many exports from scanners and loggers.

Real headers are messier than the textbook ones, and the tool deals with the common problems instead of hiding them. Two columns both called id would normally overwrite each other, so the later one is renamed id_2. An empty header cell is named after its position, for example column_4. If a report has a title and a blank line above the real header, set "Skip leading rows" so the correct row becomes the header. The "Key case" setting can leave keys as written or change them to lower case, UPPER CASE, camelCase or snake_case; nothing is renamed unless you ask.

Many exports write nested data as flat columns called address.city and address.zip. Turn on "Nest dotted headers" (dot or slash) and they fold back into an address object. It is off by default, so a column that is really named Revenue.2024 stays flat.

Array of objects or another shape?

The shape decides what the top level of the file is. They are different files, not different layouts of one file.

Output shapeLooks likeUse it for
Array of objects[{"id": 1, "name": "Ada"}]APIs, JavaScript apps, most code
Array of arrays[["id","name"],[1,"Ada"]]Matrix data, or files with duplicate or missing headers
JSON LinesOne record per line, no bracketsDatabase and log imports
Keyed hash{"SKU-1": {...}}Looking records up by an id column
Column arrays{"id": [1,2], "name": [...]}Charting and data-frame libraries

Two details are worth knowing. JSON Lines is never indented, because a record that spans several lines would break the format. And in a keyed hash, two rows with the same key value cannot both survive: the later row wins and the tool reports how many rows were replaced.

Numbers, booleans, blanks and leading zeros

A CSV file has no types: every cell is text. The setting "Read numbers, booleans and null" is on by default and turns cells into the JSON value they look like. The risk with type detection is damage, so the tool deliberately leaves some values as text.

Cell in the CSVIn the JSONWhy
42 or 3.1442 or 3.14 (numbers)Plain numbers
1,234.56 or 1.234,561234.56Both separator conventions are understood; "Number format" can force one
(1,234.50)-1234.5Accounting parentheses mean negative
TRUE, FALSE, true, falsetrue, false (booleans)What spreadsheets and code write
007 or 00123"007" or "00123" (text)Leading zeros cannot be restored once removed
12345678901234567890Stays textMore than fifteen significant digits would be rounded as a number
+15551234567Stays textA phone number, not a quantity
2024-01-15"2024-01-15" (text)JSON has no date type, so the file's own text is kept
$50 or 12%Stays textThe symbol carries meaning

Empty cells become null by default. "Blank cells" lets you choose an empty string or leave the key out of the record instead. In the array shapes, leaving a value out would shift every later column, so a blank stays null there. If one column is mixed, for example a mostly numeric column with the odd "N/A", the Columns list shows it as mixed and lets you force that column to Text, Number or Boolean.

Delimiters, quotes and line breaks inside cells

A comma is only the most common separator. Excel in many European locales writes semicolons, because the comma is the decimal mark there. Exports also use tabs (.tsv) and pipes (.psv). Auto detection compares comma, semicolon, tab and pipe by checking which one makes every row the same width, rather than counting characters, so commas inside a quoted address do not fool it. If the preview shows everything in one column or an odd split, set "Delimiter" by hand.

A cell that contains the delimiter or a line break must be wrapped in double quotes, and a quote inside it is doubled. The converter follows those rules, so a cell such as "Smith, John" stays one value and a multi-line note stays in one cell. "Quote character" can be set to single or none for the occasional file that does not follow the standard; a quote only opens a field at the start of the field, which keeps a name like O'Brien intact.

Encodings from Excel

If accents turn into strange characters, the file was read with the wrong encoding. Auto reads a byte-order mark first, then checks for valid UTF-8, then falls back to Windows-1252, which is what Excel on Western Windows writes for a plain CSV. An Excel "Unicode Text" export is UTF-16, which the tool reads correctly when you choose UTF-16LE or when the file declares itself. You can also force UTF-8, UTF-16BE or ISO-8859-1. If a file declares its own encoding, that wins over the dropdown and the tool says so. More on how Excel saves files is in opening CSV in Excel correctly.

SymptomLikely causeFix
é shows as éUTF-8 file read as Windows-1252Set Encoding to UTF-8
Curly quotes and euro signs become boxesWindows-1252 file read as UTF-8Set Encoding to Windows-1252
Spaced-out letters or null charactersUTF-16 file read as a single-byte encodingSet Encoding to UTF-16LE or Auto
Whole row in one cellWrong delimiterSet Delimiter to Semicolon or Tab
Odd first keyByte-order mark inside the keyHandled automatically for UTF-8

Size limits and checking the result

Free conversion handles one file at a time up to 25 MB, which is a very large spreadsheet export, with no feature withheld. Note that JSON is bigger than the CSV it came from, because every row repeats every key. Pretty-printing with 2 spaces, 4 spaces or a tab adds more, so choose "Minified" under Indent when size matters. Pro adds converting up to 50 files, one ZIP download and combining all files into a single array or a single JSON Lines file.

Paste the output into the JSON formatter if you want to inspect or validate it, and use JSON to CSV to go the other way; the JSON to CSV guide covers that direction.

Frequently asked questions

How do I convert a CSV file to JSON?

Drop the file into the CSV to JSON converter, keep "First row is the header" on, choose Array of objects and press Convert to JSON. Then copy the result or download the .json file. Free conversion covers one file up to 25 MB.

How do I convert an Excel file to JSON?

In Excel, use Save As and choose CSV (or Unicode Text for a UTF-16 file), then convert that CSV. Only the active sheet is saved to a CSV file, so repeat the steps for each sheet you need.

Why do my numbers or leading zeros change?

They do not: values like 007, long ID numbers, phone numbers with a plus sign, dates and amounts with symbols stay as text on purpose. Plain numbers become JSON numbers. You can also switch off "Read numbers, booleans and null" to keep every value as text.

Why are my accents or symbols garbled?

The file was decoded with the wrong encoding. Change Encoding to UTF-8 or Windows-1252 and watch the preview; Excel files written in a Western locale are usually Windows-1252.

Why is everything in one column?

The delimiter is not a comma. Set Delimiter to Semicolon, Tab or Pipe. Excel in many European locales saves with semicolons.

Is my CSV uploaded anywhere?

No. The file is read and converted on your device, not our servers, and the result goes straight to your clipboard or a download.

Keep reading

More in Documents →