CSV is how data leaves a spreadsheet; JSON is how data enters most code. If you have exported a sheet, a report, or a database table as comma-separated values and now need to feed it to an API, a config file, or a script, you need to convert CSV to JSON. The good news is that the core idea is simple: each row becomes an object, and the header row supplies the keys. The catches are all in the details, and this guide walks through both.
What the two formats actually are
A CSV file is plain text. The first line is usually a header naming each column, and every line after that is one record, with fields separated by a delimiter (a comma, most often). JSON represents the same records as a list of objects, where each field is a labeled key-value pair. So this CSV:
name,age,city
Jane,29,Boston
becomes this JSON:
[
{
"name": "Jane",
"age": "29",
"city": "Boston"
}
]
That mapping is the whole job. Everything else is handling edge cases correctly.
Convert it with the CSV to JSON tool
The fastest route for a one-off conversion is a browser tool. The CSV to JSON tool on this site does the mapping described above and nothing you have to configure beyond a couple of options. It runs entirely in your browser, so the data you paste never gets uploaded to a server, and there is no sign-up or file limit to worry about.
Steps
- Open the CSV to JSON tool.
- Paste your CSV text into the input box. You can copy straight from a spreadsheet or a saved
.csvfile. - Pick the delimiter that matches your data: comma, semicolon, or tab. Semicolons are common in exports from European locales; tabs come from TSV files.
- Leave "First row is header" checked if your first line names the columns. Uncheck it if your data starts immediately on line one.
- Read the JSON in the output panel. It updates as you type or change options, and a counter shows how many data rows were converted so you can sanity-check the total.
- Click Copy to put the JSON on your clipboard, then paste it wherever you need it.
If the header box is checked, each row becomes an object keyed by the header names. If you uncheck it, you get an array of arrays instead, one inner array per row, which is handy when your data has no meaningful column names.
The quoting trap most conversions get wrong
The single biggest source of broken conversions is a field that contains the delimiter itself. Consider a name like Smith, John in a comma-delimited file. Naively splitting on commas turns that one field into two and shifts every column after it. Proper CSV handles this by wrapping such fields in double quotes: "Smith, John". The tool parses quoted fields correctly, including quoted fields that contain line breaks, and escaped quotes written as two double-quotes ("") inside a quoted field, which collapse to a single literal quote.
If your JSON comes out with columns misaligned or a value swallowing the rest of the file, the culprit is almost always quoting: a field that should have been quoted was not, or a quote was opened and never closed in the source data. Fix the CSV rather than the JSON.
An honest caveat: everything comes out as text
This is the limit to plan around. The tool treats every value as a string, so the number 29 becomes "29", and true, false, and empty cells stay as text too. It does not guess data types. For a lot of uses that is fine, but if the system consuming your JSON expects real numbers or booleans, you will need to cast those values afterward in your code or with a follow-up transform. There is also no nesting: a flat CSV produces flat objects, so you cannot build a hierarchy of objects-within-objects from columns alone.
A few smaller things worth knowing:
- Duplicate header names will collide, because two keys with the same name cannot coexist in one object. The later column wins. Rename clashing headers in your source first.
- A blank header cell is filled in automatically with a placeholder like
column_2so no key is left nameless. - Rows with fewer fields than the header get empty strings for the missing columns rather than throwing an error.
- Output is delivered by copy only; there is no file download, so for very large datasets you are pasting into whatever comes next.
When a different approach is better
Reach for a script instead of a browser tool when the job is recurring or large. If you convert the same export every day, a few lines of Python (csv and json modules) or a Node script will do it repeatably and let you cast types, rename fields, and build nested structures in the same pass. If your file is hundreds of megabytes, a browser tab is the wrong container; use command-line tools or a streaming parser. And if your CSV is genuinely malformed, with inconsistent quoting or ragged rows, clean it in a spreadsheet first, because no converter can reliably guess what a broken file meant to say.
For the common case, though, pasting a clean export and copying the result is faster than writing any code. Convert first, then handle types and structure downstream where you have full control.