ToolNimba Browse

🔀 CSV to JSON Converter

By ToolNimba Web Dev Team · Updated 2026-06-19

JSON output
 

Paste CSV above, then press Convert to JSON.

This CSV to JSON converter turns comma-separated rows into a clean JSON array of objects. Paste your CSV, choose the delimiter (comma, semicolon, tab or pipe), and decide whether the first row is a header. The tool parses quoted fields and commas inside quotes correctly, then pretty-prints the result so you can copy it straight into your code. 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 from one to the other is one of the most common glue tasks in everyday programming.

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 with the header checkbox.

The part that trips up naive converters is quoting. The CSV convention (RFC 4180) wraps a field in double quotes when it contains the delimiter, a line break, or a quote itself, 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.

When to use it

  • Turning a spreadsheet export into a JSON array you can drop into a JavaScript or TypeScript file.
  • Seeding a database, mock API or test fixture from a CSV someone sent you.
  • Inspecting a messy CSV to confirm how quoted fields and embedded commas are actually being parsed.
  • Converting analytics or e-commerce exports (which often use semicolons or tabs) into JSON for a script.

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, then use Copy to grab the pretty-printed result.

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). Fields wrapped in quotes may contain the delimiter, newlines, or a doubled "" that decodes to one literal quote.

Worked examples

A simple CSV with a header row, 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" }

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

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.

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.

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.

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.

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 use a semicolon, tab or pipe instead of a comma?

Yes. Use the Delimiter dropdown to pick comma, semicolon, tab or pipe. Semicolons are common in European spreadsheet exports, and tabs appear in TSV files and spreadsheet copy/paste.