Skip to content

CSV to JSON Converter

Paste or open a CSV file to turn its rows into JSON objects keyed by the header. The delimiter is detected, each column gets one type, so zip codes keep their leading zeros, and a file saved by Excel opens with its accents intact.

Runs locally in your browser

More options

Input

5 lines · 214 characters
id,name,email,zip,signup_date,active,score
1,Ada Lovelace,ada@example.com,00123,2026-01-15,TRUE,98.5
2,Grace Hopper,grace@example.com,94016,2026-02-03,FALSE,87
3,Alan Turing,alan@example.com,10001,2026-03-21,true,

Output

JSON appears here

A preview of the table appears here.

What the CSV to JSON converter does

The converter reads a CSV table and writes each data row as a JSON object, with the header row supplying the keys. It reads the file the way RFC 4180 (opens in a new tab) describes: a quoted cell may contain the delimiter, line breaks and doubled quotes, and rows may end in CRLF, LF or CR. The JSON is written out as text, so a header named __proto__ is an ordinary key and every number keeps the digits it had in the file.

How to convert CSV to JSON

  1. Paste the table, or open or drop a .csv, .tsv or .txt file exported from a spreadsheet or a database.
  2. Leave Delimiter on Detect, or choose it when the summary under the output names the wrong one.
  3. Check the column types in the preview. Turn off Type inference when every value should stay a string, as for product codes.
  4. Pick the Output format, then copy the JSON or download it. Swap direction sends the result to JSON to CSV.

Examples

Types are chosen per column, so zip codes keep their zeros

Input

id,name,zip,active
1,Ada,00123,TRUE
2,Linus,94016,false

Output

[
  {
    "id": 1,
    "name": "Ada",
    "zip": "00123",
    "active": true
  },
  {
    "id": 2,
    "name": "Linus",
    "zip": "94016",
    "active": false
  }
]
A semicolon file with a decimal comma and a long product number

Input

product;price;sku
Tea;1,5;12345678901234567890

Output

[
  {
    "product": "Tea",
    "price": "1,5",
    "sku": 12345678901234567890
  }
]
Rows with a missing cell and an extra cell

Input

a,b
1,2,3
4

Output

[
  {
    "a": 1,
    "b": 2,
    "_3": 3
  },
  {
    "a": 4,
    "b": null
  }
]

How the delimiter is detected

With Detect, the converter reads the first ten rows with each candidate, a comma, a semicolon, a tab and a pipe, and keeps the one that splits every row into the same number of cells, at least two. Quoted cells count as one cell during the test, so a comma inside "Doe, Jane" does not mislead it. The summary under the output names the delimiter that was used.

Regional settings explain most semicolon files: where the comma is the decimal mark, Excel writes 1,5 for one and a half and separates cells with semicolons instead. A file of a single column has no delimiter to find; it is read with commas and a warning, which you can ignore for a one-column list.

Header rows

The first row names the keys. A header cell that appears twice gets a number, so email, email becomes email and email_2, and an empty header cell becomes column_3 for the third column, each with a warning. If the file starts directly with data, turn off Header row: the keys are then column_1, column_2 and so on, or choose Array of arrays as the Output to get each row as a plain list.

Why a zip code stays text

Type inference decides once per column. A column turns into numbers only when every filled cell is a valid JSON number, and into true and false only when every filled cell is one of those words, in any case, as Excel writes TRUE and FALSE. One cell that does not fit keeps the whole column as text, so the zip code 94016 stays a string beside 00123, and a column never mixes numbers with strings.

Numbers are copied as written. 00123, +1, 1. and 1,5 are not JSON numbers and stay strings, while 1e3 and -0 are written exactly like that. A whole number above 9,007,199,254,740,991 is kept in full, with a note: most JSON readers round it, which the JSON Formatter explains. For ID columns, turning off Type inference is the safer choice.

Nested JSON from dotted headers

With Unflatten keys on, a header such as user.name puts its value inside an object: {"user": {"name": "Ada"}}. Headers that end in .0, .1 and onward to one less than their count build a list, so tags.0 and tags.1 become "tags": ["x", "y"]; numbers with a gap, like .1 and .2 alone, build an object instead. When one header is both a value and a parent, as with a and a.b, neither can be nested: both stay flat keys and the Problems list says so. The Key separator sets the character that splits the headers.

Rows with missing or extra cells

Rows exported by hand-written scripts are not always the same length. A short row gets null for each missing cell. A long row keeps its extra cells under keys named after their position, like _3 for the third column, and only that row has them. Every such row is listed under Problems with its line number, so a stray delimiter is easy to find.

Accents and file encodings

An opened file is read as UTF-8 first. When its bytes are not valid UTF-8, it is read again as Windows-1252, the encoding Excel uses for "CSV (Comma delimited)" files on Windows, and a warning appears under the input. That turns the byte E9 into é and 80 into the euro sign instead of replacement characters. Files saved as "CSV UTF-8" start with a byte order mark, which the converter skips.

JSON array or JSON Lines

A JSON array suits most uses: an API body, a fixture, a configuration. JSON Lines writes one object per line with no surrounding brackets, which log processors, BigQuery and many streaming tools read one line at a time; its download is a .jsonl file. Array of arrays keeps the table's shape, with the header as the first list.

Options

Options
OptionValuesDefaultWhen to change it
DelimiterDetect, Comma (,), Semicolon (;), Tab, Pipe (|)DetectChoose the delimiter yourself when detection picks the wrong one, for example in a file with very few rows.
Header rowOn, OffOnTurn it off for files without a header; the keys become column_1, column_2 and so on.
Type inferenceOn, OffOnTurn it off to keep every value a string, which suits IDs, product codes and phone numbers.
OutputJSON array, JSON array, minified, JSON Lines, Array of arraysJSON arrayJSON Lines for log and data pipelines, arrays of arrays to keep the table's shape.
Empty cellsnull, Empty string (""), Leave the key outnullLeave the key out for sparse records; in a list, an empty cell is always null.
Unflatten keysOn, OffOffBuilds nested objects and lists from headers like user.name and tags.0.
Key separatorDot (.), Slash (/), Underscore (_)Dot (.)The character that splits headers when Unflatten keys is on.
Parse JSON in cellsOn, OffOffCells that start with { or [ and hold valid JSON become objects and lists, numbers kept as written.
Remove spreadsheet-safe prefixOn, OffOffTakes off the apostrophe a spreadsheet-safe export puts before text like =SUM(A1). A value that really started with that apostrophe loses it too.
Skip empty linesOn, OffOnTurn it off to keep each empty line as a row of empty cells.

Common errors and fixes

Common errors and how to fix them
CodeWhat it meansHow to fix it
CSV_UNCLOSED_QUOTEErrorA cell opens a double quote that never closes, so the rest of the file would be one cell.Close the quote, or write a quote inside a cell as two quotes, "".
CSV_MALFORMED_QUOTEWarningText follows a closing quote, as in "5" screen, where the quote was meant as inches.Double the inner quotes: "5"" screen". The converter keeps the text but warns.
CSV_FIELD_COUNT_MISMATCHWarningA row has more or fewer cells than the header, often from an unquoted delimiter inside a value.Quote the value that contains the delimiter, or add the missing cells.
CSV_DELIMITER_UNDETECTEDWarningNo delimiter splits the first rows into two or more columns: the file has one column, or very few rows.Ignore it for a one-column list; otherwise choose the Delimiter.
CSV_ENCODING_FALLBACKWarningThe file is not UTF-8, so it was read as Windows-1252.Check a few accented words. If they are still wrong, export the file again as CSV UTF-8.
CSV_DUPLICATE_HEADERWarningTwo columns have the same name, which would make one key hide the other.Rename one of them in the header, or keep the numbered name the converter gave it.
CSV_EMPTY_HEADERWarningA header cell is empty, often a leftover first column of row numbers.Name the column, or keep the column_N key it was given.
CSV_UNFLATTEN_CONFLICTWarningWith Unflatten keys, one header is both a value and the parent of another, like a and a.b.Rename one of the headers, or turn off Unflatten keys.
CSV_SAFE_PREFIX_DETECTEDNoteCells start with an apostrophe before =, +, - or @, the mark of a spreadsheet-safe export.Turn on Remove spreadsheet-safe prefix to get the original values back.
CSV_NO_DATA_ROWSNoteThe file has a header row and nothing below it.Check that the right file was opened; the output is an empty array.

Privacy

CSV to JSON runs entirely in your browser. What you type, paste or open is processed on your device: it is not sent to Toolzami, and Toolzami does not store it. Only the options you choose are remembered, in this browser.

Frequently asked questions

Can I convert an Excel .xlsx file?

Not directly. In Excel, use File > Save As and choose CSV UTF-8; in Google Sheets, use File > Download > Comma-separated values. Then open that file here.

How do I rename the keys in the JSON?

Edit the header row before converting: each header cell becomes a key exactly as written. With Unflatten keys on, a header such as address.city also decides where the value goes.

Last updated