ToolNimba

๐Ÿ”€ CSV to JSON Converter: Convert CSV to JSON Online

Shihab Mia By Shihab Mia ยท Updated 2026-07-05

JSON output
 

Paste CSV above, then press Convert to JSON.

To convert CSV to JSON, paste your CSV below, choose the delimiter (comma, semicolon, tab or pipe), keep the header toggle on, and press Convert. This CSV to JSON converter turns comma-separated rows into a clean, pretty-printed JSON array of objects, correctly parsing quoted fields and commas inside quotes per RFC 4180. Everything runs in your browser, so your data is never uploaded anywhere.

What is the CSV to JSON?

CSV (comma-separated values) is a plain-text table: each line is a row, and each value in a row is separated by a delimiter, usually a comma. It is the lowest common denominator for tabular data, exported by spreadsheets, databases and analytics tools alike. JSON (JavaScript Object Notation) is the structured format that web APIs and JavaScript apps expect, where data is expressed as arrays and key/value objects. Converting CSV to JSON is one of the most common glue tasks in everyday programming, and doing it correctly means respecting the quoting rules that naive splitting ignores.

When the first row holds column names, the natural conversion is an array of objects: each later row becomes one object whose keys are the header names and whose values are that row cells. So a CSV of "name,age" over two data rows becomes [{"name":"Ada","age":"36"}, ...]. If there is no header row, the safe output is an array of arrays, preserving the raw cell order without inventing key names. This tool lets you toggle between the two shapes with the header checkbox, so you get the JSON structure your code actually expects.

The part that trips up naive converters is quoting. The CSV convention defined by RFC 4180 wraps a field in double quotes when it contains the delimiter, a line break, or a quote character, and a literal quote inside is written as two double quotes. That means "London, UK" is a single field even though it contains a comma, and "Said ""bug"" first" decodes to the text Said "bug" first. A correct parser reads character by character, tracking whether it is currently inside a quoted field, rather than just splitting on commas. This converter does exactly that, so embedded commas, quotes and even newlines inside a quoted field survive the round trip intact.

CSV carries no type information, which is the second thing that surprises people. Every cell is text, so the number 36 arrives as the string "36", the word true arrives as "true", and a blank cell arrives as an empty string. JSON, by contrast, distinguishes strings, numbers, booleans and null. Because guessing types is risky (think of a ZIP code like "01730" that must not lose its leading zero, or a product code that looks numeric but is not), this tool keeps every value as a string by default and leaves the casting decision to you. Convert with Number(), parseFloat(), or an explicit check against "true" in your own code where you are sure of the column meaning.

Delimiters are the third common snag. Although "comma-separated" is in the name, real files often use other separators. Spreadsheets in locales that use a comma as the decimal mark (much of Europe) export semicolons instead, tab-separated TSV files come from databases and copy-paste, and pipe-delimited exports are popular precisely because the data itself may contain commas. If your converted JSON shows one giant key holding an entire row, the delimiter is wrong: switch it in the dropdown and convert again. The right delimiter is the single most important setting for a clean result.

Finally, remember that CSV to JSON is a structural transform, not a validation step. The converter faithfully mirrors whatever is in your file, including trailing spaces, duplicate headers, ragged rows with too few or too many columns, and stray blank lines. Clean the source where you can (deduplicate headers, trim whitespace, remove empty trailing lines) so the JSON that comes out is as tidy as the data going in. Because the whole process happens locally in your browser with no upload, it is also safe to run on private, sensitive or proprietary spreadsheets.

When to use it

  • Turning a spreadsheet export into a JSON array you can drop straight into a JavaScript or TypeScript file.
  • Seeding a database, mock API or test fixture from a CSV a colleague or client sent you.
  • Inspecting a messy CSV to confirm exactly how quoted fields and embedded commas are being parsed.
  • Converting analytics or e-commerce exports (which often use semicolons or tabs) into JSON for a script.
  • Feeding tabular data into a REST API, config file or front-end app that only accepts JSON.
  • Prototyping quickly by pasting a few rows and getting a JSON payload without writing any parser code.

How to use the CSV to JSON

  1. Paste your CSV into the input box, or press Load sample to see the expected format.
  2. Pick the delimiter that separates your values: comma, semicolon, tab or pipe.
  3. Leave "First row is a header" ticked to get an array of objects, or untick it for an array of arrays.
  4. Press Convert to JSON to generate the pretty-printed result.
  5. Use Copy to grab the JSON, then paste it into your code, API request or file.

Formula & method

With a header row: output = rows.slice(1).map(row => Object.fromEntries(headers.map((h, i) => [h, row[i] ?? ""]))). Without a header row: output = rows (an array of arrays). Parsing rule (RFC 4180): fields wrapped in double quotes may contain the delimiter, newlines, or a doubled "" that decodes to one literal quote; the parser walks character by character tracking in-quote state rather than splitting on the delimiter.
CSV (comma-separated)name,age,cityAda,36,LondonGrace,41,"New York"header row + 2 data rowsconvertJSON (array of objects)[{ "name":"Ada", "age":"36",  "city":"London" },{ "name":"Grace", "age":"41",  "city":"New York" }]keys come from the header row;values stay as strings (no CSV types)Quoted "New York" stays one field even with a comma inside.Runs in your browser; nothing is uploaded.

Worked examples

A simple CSV with a header row and comma delimiter: "name,age,city" followed by "Ada,36,London".

  1. The first row is read as the header: ["name", "age", "city"].
  2. The data row "Ada,36,London" splits into ["Ada", "36", "London"].
  3. Each value is paired with its header by position.
  4. Numbers stay as strings ("36") because CSV has no types; cast them later if needed.

Result: [ { "name": "Ada", "age": "36", "city": "London" } ]

A row with a comma and an escaped quote inside quoted fields: Grace,41,"New York","Said ""bug"" first".

  1. The parser sees the opening quote and reads until the matching closing quote, so "New York" is one field.
  2. Inside the last field, the doubled "" is decoded to a single literal quote.
  3. "Said ""bug"" first" therefore becomes the text: Said "bug" first.
  4. The embedded characters survive because parsing tracks quote state instead of splitting on commas.

Result: { "name": "Grace", "age": "41", "city": "New York", "note": "Said \"bug\" first" }

A semicolon-delimited export with no header row: "Apple;1.20" and "Pear;0.90", header toggle off.

  1. The delimiter dropdown is set to semicolon so each line splits on ";".
  2. Because the header toggle is off, no keys are invented and the output is an array of arrays.
  3. Row one becomes ["Apple", "1.20"] and row two becomes ["Pear", "0.90"].
  4. Prices remain strings ("1.20"); wrap them in Number() in your code if you need real numbers.

Result: [ ["Apple", "1.20"], ["Pear", "0.90"] ]

How a CSV maps to JSON depending on the header toggle

Header row?JSON shapeExample output
Yes (ticked)Array of objects[{"name":"Ada","age":"36"}]
No (unticked)Array of arrays[["name","age"],["Ada","36"]]

Common delimiters and where you see them

DelimiterNameTypical source
,CommaStandard CSV, US/UK spreadsheet exports
;SemicolonExcel in locales that use a comma as the decimal mark
\tTabTSV files, copy/paste from spreadsheets
|PipeDatabase and log exports that may contain commas

How CSV text values map to JSON value types

CSV cellDefault JSON outputCast in code if you want a real type
36"36" (string)Number("36") => 36
true"true" (string)"true" === value => true
01730"01730" (string)Keep as string to preserve the leading zero
(empty cell)"" (empty string)Map "" to null yourself if needed

Common mistakes to avoid

  • Splitting on commas and breaking quoted fields. A plain text.split(",") cuts "London, UK" into two pieces and corrupts every following column. Quoted fields must be parsed by tracking quote state, which is what this tool does.
  • Expecting numbers and booleans to be typed. CSV has no data types, so every value comes through as a string ("36", "true"). Cast them in your code with Number() or a check against "true" after conversion if you need real numbers or booleans.
  • Using the wrong delimiter. Files from non-US locales often use a semicolon or tab. If your JSON has one giant key per row, the delimiter is wrong; switch it before converting.
  • Duplicate or blank header names. If two columns share a header, the later value overwrites the earlier one because object keys must be unique. Rename duplicate headers in the source first, or convert without a header row.
  • Ignoring a leading zero or long number. A ZIP code like "01730" or a 16-digit card number loses meaning if cast to a number. Keep such columns as strings so the leading zero and full precision survive.
  • Leaving stray blank lines or trailing spaces. Empty trailing lines can produce an object of empty strings, and untrimmed cells carry hidden spaces into your keys and values. Clean the source so the JSON stays tidy.

Glossary

CSV
Comma-separated values: a plain-text format where each line is a row and a delimiter separates the values within a row.
JSON
JavaScript Object Notation: a structured text format of arrays and key/value objects used widely by APIs and apps.
Delimiter
The character that separates fields in a row, most often a comma but sometimes a semicolon, tab or pipe.
Header row
The first row of a CSV that names the columns; these names become the keys in the JSON objects.
Quoted field
A value wrapped in double quotes so it can safely contain the delimiter, a line break, or quote characters.
RFC 4180
The informal standard that defines common CSV rules, including how quoting and escaped double quotes work.
Array of objects
JSON shape where each row is an object keyed by the header names, the default output when a header row exists.
TSV
Tab-separated values: the same idea as CSV but using a tab character as the delimiter between fields.

Frequently asked questions

How do I convert CSV to JSON?

Paste your CSV into the box above, choose the delimiter, keep the header toggle on if the first row holds column names, and press Convert to JSON. The tool returns a pretty-printed JSON array of objects you can copy. It all runs locally in your browser.

How do I convert CSV to a JSON array of objects?

Keep "First row is a header" ticked. The converter reads the first row as the column names and turns every following row into an object whose keys are those names, producing a JSON array of objects like [{"name":"Ada","age":"36"}]. Untick the toggle to get an array of arrays instead.

Does the converter handle commas inside quoted values?

Yes. Fields wrapped in double quotes can contain the delimiter, line breaks, and quote characters. A value like "London, UK" stays as one field, and a doubled "" inside a quoted field is decoded to a single literal quote, following the RFC 4180 convention.

What happens if my CSV has no header row?

Untick "First row is a header" and the tool outputs an array of arrays instead of an array of objects, preserving the raw cell order of every row without inventing key names.

Why are my numbers shown as strings in the JSON?

CSV stores no type information, so every value is read as text and "36" comes through as the string "36". Cast values to numbers or booleans in your own code after conversion if you need typed data. This also protects leading zeros in codes like "01730".

Is my data uploaded to a server?

No. The conversion happens entirely in your browser with vanilla JavaScript. Nothing you paste is sent over the network, which makes the tool safe for private or sensitive spreadsheets.

Can I convert TSV or use a semicolon or pipe instead of a comma?

Yes. Use the Delimiter dropdown to pick comma, semicolon, tab or pipe. Choose tab for TSV files, semicolon for many European spreadsheet exports, and pipe for database and log exports whose data may contain commas.

Can I convert a large CSV file to JSON?

Yes, within the limits of your browser memory. Because the tool runs client-side, very large files (hundreds of thousands of rows) may be slow or hit browser limits; for those, a streaming parser in Node.js or Python is a better fit. For typical spreadsheet exports the in-browser converter is instant.

How do I handle duplicate column headers?

JSON object keys must be unique, so if two columns share a header the later value overwrites the earlier one. Rename the duplicate headers in your source file first, or convert without a header row to get an array of arrays that keeps every column.

How do I convert the JSON output back into CSV?

Reverse the process with a JSON to CSV tool: take the array of objects, use the object keys as the header row, and join each object values with your chosen delimiter, quoting any value that contains the delimiter, a quote or a newline.

Sources