CSV to JSON Converter
Convert CSV to a JSON array of objects in your browser. Handles quoted fields, commas inside values, and Windows line endings. Nothing is uploaded.
Your stuff stays yours. The conversion happens in this page's JavaScript. Nothing you paste here leaves your machine, and the tool keeps working with the network unplugged.
The first CSV row is treated as the header and becomes the JSON keys; every following row becomes one object. The parser follows RFC 4180 rules: quoted fields may contain commas and line breaks, doubled quotes inside a quoted field become a literal quote, and Windows line endings are handled.
How to use the CSV to JSON converter
- Open your CSV in a text editor (not a spreadsheet view), select everything, and paste it into the CSV in box. Make sure the first line is the header row.
- Click Convert to JSON.
- Read the result in the JSON out box. It is an array with one object per data row, indented two spaces, with keys in the same order as your header columns.
- Click Copy result to take the JSON with you, or Clear to reset both boxes.
How the parser reads your file
CSV looks simple, but the details decide whether your data survives. Here is exactly what this converter does with each part of the input.
- The separator is always a comma. Semicolons, tabs, and pipes are treated as ordinary characters inside a field.
- A quote character turns quoted mode on. In a field wrapped in
", everything up to the closing quote (commas and line breaks included) is part of the value, and""stands for one literal quote. The quote marks themselves are not kept. A quote in the middle of an unquoted field also turns quoted mode on, which causes one of the problems described below. - Line endings are normalized. Windows (CRLF) and old Mac (CR) line breaks are converted to plain line feeds before parsing, so a multi-line quoted value comes out with
\nin the JSON. - Blank lines are skipped, including a trailing newline at the end of the file. A line containing only commas is not blank: it becomes an object whose values are all empty strings.
- Whitespace is kept. A space after a comma becomes part of the next value, and a space in the header becomes part of the key.
- Row length is matched to the header. Missing cells become
"", and cells beyond the last header column are dropped without a warning. - A header with no data rows produces an empty array,
[].
A worked example
This CSV has a comma inside a name, doubled quotes, a line break inside a quoted field, and a row with two empty cells at the end:
id,name,city,notes
1,"Lovelace, Ada",London,"Said ""hello"""
2,Grace Hopper,Arlington,"Line one
Line two"
3,Alan Turing,,
Clicking Convert to JSON gives:
[
{
"id": "1",
"name": "Lovelace, Ada",
"city": "London",
"notes": "Said \"hello\""
},
{
"id": "2",
"name": "Grace Hopper",
"city": "Arlington",
"notes": "Line one\nLine two"
},
{
"id": "3",
"name": "Alan Turing",
"city": "",
"notes": ""
}
]
The surrounding quotes are removed from each value, the doubled quotes collapse to one (shown as \" because JSON escapes quotes inside strings), and the line break inside the second note is kept. The ids stay strings, "1" rather than 1.
Common problems and how to fix them
Every row became one key full of semicolons
Spreadsheet apps in regions that use a comma as the decimal mark often save CSV with semicolons between fields. The converter only splits on commas, so name;role turns into a single key. Export again with a comma delimiter, or replace the semicolons in a text editor first (after checking that no values contain semicolons of their own).
Half the file ended up inside one value
A quote character in the middle of an unquoted field, like 5" screen, switches the parser into quoted mode. Everything after it, including later rows, is read into that one field until another quote shows up, and no error is shown. Unterminated quotes behave the same way. Look for stray " characters and wrap those fields properly: "5"" screen".
Keys have leading spaces
A header like name, role produces the keys "name" and " role", and your code looking up role finds nothing. Remove the spaces after commas in the header row, and in the data too if the values matter.
A column is missing from the output
Two header cells with the same name map to the same JSON key, so the column further right overwrites the one before it. Rename one of the duplicate headers. If instead a data row has more cells than the header, the extras are dropped; add a header name for them.
Leading zeros are already gone
The converter keeps values exactly as text, so if 02134 shows up as 2134, the zero was lost earlier, usually when the file was opened and saved in a spreadsheet app. Export from the original source instead.
Related tasks
To turn JSON back into rows for a spreadsheet, use the JSON to CSV converter. If you want the output as YAML instead, pass it through the JSON to YAML converter. Duplicate rows can be removed before converting with remove duplicate lines, as long as none of your records span several lines.
Questions this tool gets asked
How are commas inside values handled?
Fields wrapped in double quotes are parsed as single values even when they contain commas or line breaks, per RFC 4180.
What happens when a row has fewer columns than the header?
Missing cells become empty strings, so every output object has the same set of keys.
Are numbers converted to JSON numbers?
No. Every value stays a string, because CSV carries no type information and guessing corrupts data like ZIP codes and phone numbers. Cast types downstream where you know the schema.
Related tools
- statement → csvStatement PDF in, clean transaction CSV/Excel out - never uploaded.
- stl → gcodeReal CuraEngine slicing in your tab - STL in, G-code out.
- psd → pngPhotoshop file in, flattened PNG out - parsed locally, never uploaded.
- pdf → csvPDF tables out as CSV - bank statements never leave your machine.