Free developer tool

Turn a CSV with a header row into an array of JSON objects

A CSV to JSON converter online for developers and analysts who need spreadsheet rows as JSON for an API, a test fixture or a script. Parsing happens in your browser; the CSV is never uploaded.

Header names become object keysQuoted commas and line breaks handledDownload the result as converted.json
CSV to JSON

Paste CSV with a header row on the left and convert it. The JSON array appears on the right, ready to copy or save as converted.json.

Runs on your device
JSON
The JSON array appears here.

What the CSV to JSON does

CSV to JSON takes comma-separated text pasted into a box and, when you press Convert, treats the first row as the list of column names and every following row as one record. Each record becomes a JSON object whose keys are the header names and whose values are the cells in that row. The result is an array of those objects, indented by two spaces, with a message such as Converted 42 data rows. You can copy it or download it as converted.json.

The parser follows the quoting rules of RFC 4180. A field wrapped in double quotes may contain commas and line breaks, and a double quote inside such a field is written as two double quotes. Rows may end with a line feed, a carriage return or both, so files from Windows, macOS and Linux all parse. Rows in which every cell is empty are skipped, which removes the blank line that many exports leave at the end.

Every value in the output is a JSON string. The converter does not guess whether 007 is a number, whether TRUE is a boolean or whether 2026-10-14 is a date, because CSV carries no type information and guessing wrongly corrupts identifiers, postcodes and phone numbers. Convert types in your own code, where you know what each column means.

The tool suits exports from spreadsheets, CRM systems and databases that use commas as the separator. It does not handle semicolon- or tab-separated files, and there is no file picker, so it is built for pasting a few hundred rows rather than processing a large data dump.

How to use it

Paste the CSV text

Include the header row as the first line. The placeholder shows the shape: name,email on the first line, then one person per line underneath.

Press Convert CSV to JSON

The JSON appears in the box on the right with a row count. If parsing fails, the message tells you why: an unclosed quoted field, duplicate header names, or fewer than two rows.

Copy or download

Copy puts the text on the clipboard; Download JSON saves it as converted.json with the application/json type, ready for a fixtures folder or an import script.

How the parser reads your CSV

The text is read one character at a time. A comma outside quotes ends a field, a line break outside quotes ends a row, and a double quote toggles between quoted and unquoted mode. Inside a quoted field, two double quotes in a row become one literal quote, and commas and line breaks are kept as part of the value. If the text ends while a quoted field is still open, conversion stops with the message A quoted CSV field is not closed, which usually points to an unbalanced quote somewhere above.

One consequence of the toggle rule matters for messy data: a double quote in the middle of an unquoted field, such as 5" screen written without surrounding quotes, switches the parser into quoted mode and swallows the commas and line breaks that follow until the next quote. RFC 4180 requires fields containing quotes to be enclosed in quotes with the inner quotes doubled; exports from spreadsheet software do this, but hand-edited files often do not.

How headers become keys

Each cell in the first row is trimmed of surrounding spaces and used as a property name exactly as written, so a header of First Name produces the key "First Name", which is valid JSON but awkward to reach with dot notation in JavaScript. An empty header cell is replaced by a generated name based on its position: column_1, column_2 and so on. If two headers are identical after trimming, conversion stops with Header names must be unique, because a second value would silently overwrite the first.

Data cells, unlike headers, are not trimmed. A row with fewer cells than the header row is padded with empty strings for the missing columns. A row with more cells than the header row is truncated to the header count without a warning, so if a count in the result looks wrong, check for an unquoted comma in the source.

  • Header cells: trimmed, must be unique, blank ones become column_N
  • Data cells: kept as typed, always strings, missing ones become ""
  • Extra cells beyond the header count: dropped silently
  • Rows where every cell is empty: skipped

Why every value is a string, and what to do about it

JSON distinguishes numbers, booleans, null and strings; CSV has only text. Any automatic conversion has to guess, and the common guesses go wrong on real data: a product code of 007 loses its zeros as the number 7, a UK postcode beginning with a digit may be parsed as a number, 1e3 becomes 1000, and an empty cell becomes null in some tools and an empty string in others. This converter makes none of those guesses and writes an empty cell as "".

Convert types where the meaning is known. In JavaScript that is Number(row.price) for a price column and row.active === "true" for a flag; in Python, int() and a comparison do the same. If you need numbers in the JSON itself, run the output through a short script with a per-column mapping rather than a generic rule.

Limits to know before you rely on it

  • Only commas are recognised as delimiters. Semicolon-separated exports, common from spreadsheets in European locales, and tab-separated files must be converted to comma-separated form first.
  • Every value is written as a JSON string. Numbers, booleans, dates and nulls are not detected.
  • A row with more cells than the header row is truncated without a warning; a row with fewer cells is padded with empty strings.
  • A stray double quote in an unquoted field starts a quoted section and can swallow the commas and line breaks that follow it.
  • The CSV must be pasted into the text box; there is no file picker, so very large files are impractical.
  • Output always uses two-space indentation as an array of objects. There is no option for minified output, a different key style or nested structures.

Questions people ask about the CSV to JSON

Why do I get Header names must be unique?

Two or more cells in the first row are the same after trimming spaces, for example two columns both called name, or two blank headers were filled with the same text. Rename the duplicates in the header row so that every column has its own key, then convert again.

Can a value contain a comma or a line break?

Yes, if the field is wrapped in double quotes. A field such as "Lahore, Punjab" stays one value, and a quoted address spanning two lines stays one value with the line break inside it. A double quote inside a quoted field must be doubled, as in "5"" screen".

Why are my numbers wrapped in quotes in the JSON?

Because the converter writes every cell as a string rather than guessing types. This protects codes with leading zeros, postcodes, phone numbers and long identifiers. Convert the columns you know to be numeric in your own code after loading the JSON.

What does a key like column_3 mean?

The third cell of your header row was empty, so the converter generated a name from its position. Give the column a real header in the source if you want a meaningful key, keeping in mind that it must not duplicate another header.

My spreadsheet exported with semicolons. Can I still use this?

Not as exported. Re-export with a comma delimiter if the software offers the choice, or open the file in the spreadsheet and save it as CSV (comma delimited). Replacing semicolons with commas in a text editor works only when no value contains a comma of its own.

Does the converter keep empty rows?

No. A row in which every cell is empty is skipped, which is how a trailing blank line at the end of a file is removed. A row with at least one non-empty cell is kept, with its missing columns written as empty strings.

Sources and further reading