CSV to JSON — Convert CSV Rows to a JSON Array
Part of Text tools: See all Text tools.
What is CSV To JSON?
CSV to JSON Converter turns comma-separated (or semicolon, tab or pipe separated) rows into a JSON array of objects. By default the first row supplies the keys and every following row becomes one object. Quoted fields are parsed per RFC 4180, so commas, double quotes and line breaks inside quotes stay part of the value. It runs in your browser; the CSV is not uploaded.
How to use CSV To JSON
- Paste your CSV into the box, or open a .csv or .tsv file from your device.
- Leave the delimiter on Auto-detect, or pick comma, semicolon, tab or pipe yourself.
- Untick "First row is headers" if your file has no header row; keys then become column1, column2 and so on.
- Click Convert to JSON, then copy the result or download it as converted.json.
Why use this tool?
APIs, NoSQL databases and JavaScript apps expect JSON, while spreadsheets and most database exports give you CSV. Splitting CSV on commas by hand breaks as soon as a value contains a comma, a quote or a line break, which real exports often do. This converter handles those cases and tells you how many rows and columns it read, so you can spot a wrong delimiter straight away.
CSV To JSON — In-Depth Guide
The most common reason a CSV to JSON conversion goes wrong is not the JSON side but the CSV side. A product description with a comma, an address split over two lines, or a quote mark in a name all break a simple split-on-comma script. Spreadsheet programs protect such values by wrapping them in double quotes, and this converter follows the same rules (RFC 4180), so the value you see in Excel is the value you get in JSON.
Many European versions of Excel save "CSV" with semicolons, because the comma is the decimal separator there. Leave the delimiter on Auto-detect and a file like name;price / Widget;1,50 is read as two columns, with 1,50 kept as the string "1,50" rather than misread as a number. Tab-separated files copied straight out of a spreadsheet also work.
Type conversion is on by default because most people want numbers as numbers. It is deliberately cautious: it never turns 007, 0123 or a long order ID into a number, since that would strip leading zeros or round the last digits. Dates stay as text, because CSV has no date type and guessing between 03/04 as March or April causes worse bugs than leaving it alone. Untick the option if your target system expects every field as a string.
After converting, check the row and column count shown under the output. If it reports one column when you expected several, the delimiter is wrong; if it reports more rows than your sheet, a quote is probably missing somewhere. For tidy output in another project, run the result through the JSON Formatter, and use JSON to CSV for the reverse direction.
Two formats, two world views
CSV and JSON both store tabular-ish data, but they think about it differently, and most conversion headaches come from the gap between the two. CSV is positional and flat: a header row names the columns, and every following line is a set of values separated by commas, understood purely by their order. JSON is named and nested: data is a structure of key-value pairs that can contain arrays and other objects to any depth, and values carry a type — string, number, boolean, null. Converting CSV to JSON means taking the flat, position-based, everything-is-a-string world of CSV and lifting it into the named, typed, potentially nested world of JSON. The tool does the lifting; knowing what it is doing lets you feed it clean input and trust the output.
How the conversion actually maps
The standard transformation is the one this tool performs: read the first row as headers, then turn each subsequent row into a JSON object whose keys are those headers and whose values are that row's cells. The whole file becomes a JSON array of objects — one object per data row. So a CSV with headers name,age,city and a row Asha,29,Chennai becomes {"name":"Asha","age":29,"city":"Chennai"}, and the file is an array of all such objects. This array-of-objects shape is exactly what REST APIs, JavaScript front-ends, and document databases expect, which is why this is the single most common data-prep step in everyday web work.
Notice that age came out as the number 29, not the string "29". That type inference is a convenience and a hazard at the same time, and it deserves its own section.
Type inference: helpful until it isn't
In CSV every value is text — the format has no way to say "this is a number". A good converter infers types: cells that look like numbers become JSON numbers, true/false become booleans, empty cells often become null or empty strings. Usually this is what you want. The trouble is the values that look like one type but mean another. A US ZIP code like 02134 is not the number 2134 — converting it loses the leading zero and corrupts the data. A phone number, an order ID like 0007, a version string like 1.10 (which is after 1.9, not equal to 1.1) — all of these are identifiers that happen to be made of digits, and treating them as numbers quietly breaks them.
The defensive habit: scan your headers and ask which columns are identifiers rather than quantities. Anything you would never do arithmetic on — IDs, codes, postal codes, phone numbers — should stay a string. If your data has such columns, the cleanest fix is at the source: quote those values or prefix them so they are unambiguous, and always eyeball the JSON output for the telltale dropped leading zero before you ship it to a database.
The comma-inside-a-value problem
CSV's defining weakness is that its delimiter — the comma — also appears inside real data. An address like Chennai, Tamil Nadu or a product name like "Bolt, 3mm" contains commas that are not column separators. The CSV standard handles this by wrapping such fields in double quotes: "Chennai, Tamil Nadu" is one field, commas and all. A naive split-on-comma converter will shatter that into two columns and misalign every field after it for that row. This tool parses quoted fields correctly, so commas, and even embedded newlines, inside a properly quoted value are preserved as part of a single JSON value rather than splitting the record.
Two related gotchas worth knowing. First, a literal double-quote inside a quoted field is escaped by doubling it (""), so "She said ""hi""" means She said "hi". Second, not every "CSV" is comma-separated — European exports often use semicolons (because the comma is their decimal separator), and some use tabs. If your output looks like every row collapsed into one giant field, your file probably is not actually comma-delimited, and the fix is to convert the delimiter or re-export with commas before pasting.
Where this fits in a real workflow
The conversion is rarely the goal in itself — it is the bridge between a spreadsheet world and a code world. Analysts export a dataset from Excel or Google Sheets as CSV and convert it to JSON to feed a visualisation library like D3.js or Chart.js, which want named fields rather than positional columns. Developers convert CSV exports into JSON to seed a database, build test fixtures, or stub out an API response during development. Teams migrating between systems often use JSON as the interchange format because the legacy system exports CSV and the new platform imports JSON. In every one of these, the value of the tool is removing the need to write and debug a one-off parsing script that has to handle the quoting and type edge cases above.
Getting clean output, every time
A few habits make the result reliably good. Clean your headers first — they become JSON property names, so prefer first_name over First Name (legal); spaces and punctuation in keys are legal JSON but awkward to reference in code as obj.first_name versus obj["First Name (legal)"]. Confirm the first row really is headers and not a data row, or your column names will be a person's actual values. Check the types in the output for the identifier columns discussed above. And once you have the JSON, our JSON formatter will pretty-print and validate it so you can read and sanity-check the structure, while the reverse trip is a paste away with our JSON-to-CSV tool when you need to hand data back to a spreadsheet user.
Frequently asked questions
- Does the first row need to be headers?
- No. With "First row is headers" ticked (the default), the first row becomes the JSON keys. Untick it and every row is treated as data, with keys column1, column2 and so on. Empty header cells also get a columnN name, and a repeated header such as two "name" columns becomes name and name_2 so no value is overwritten.
- How does it handle commas, quotes and line breaks inside a field?
- Wrap the field in double quotes, as Excel and Google Sheets do when they export. Inside quotes the delimiter and line breaks are kept as part of the value, and a doubled quote ("") becomes one quote character. If a quote is never closed you get an error instead of a silently shifted table.
- Does it convert numbers and true/false?
- Yes, while "Convert numbers, true/false and null" is ticked. Plain numbers like 25, -0.5 or 1.5e3 become JSON numbers, true and false become booleans and null becomes null. Values with leading zeros such as 007 or a ZIP code, and whole numbers too long to store exactly (like 20-digit IDs), stay strings so no digits are lost. Untick the box to keep every value as a string.
- Which delimiters are supported?
- Comma, semicolon, tab and pipe. Auto-detect counts each of them outside quotes in the first few lines and picks the most common one; the result line under the output tells you which it used. Choose the delimiter yourself if the guess is wrong, for example for a semicolon file whose values contain lots of commas.
- What if rows have different numbers of columns?
- A short row gets empty strings for its missing columns. A row with extra values gets extra keys named after their position (column4, column5 ...), so nothing is dropped.
- Is my data uploaded?
- No. The parsing runs in JavaScript in your browser, and opening a file reads it locally. Nothing you paste is sent to our server.
Also try
Related tools that work well with this one: