CSV to JSON Converter

Turn CSV with a header row into a JSON array of objects, or JSON objects into CSV. Handles quoted commas, doubled quotes and line breaks in your browser.

The interactive tool loads here when JavaScript runs.

About this tool

What is the CSV to JSON Converter?

The CSV to JSON Converter turns comma-separated rows into a JSON array of objects, using the first row as the property names. It also works in reverse: give it a JSON array of objects and it produces CSV with a header row.

Parsing uses Papa Parse, so quoted fields with embedded commas, doubled quotes and line breaks come through intact, and malformed quoting produces an error instead of silently shifting columns. Duplicate header names and rows with more fields than the header are rejected, because either would lose data.

In the JSON to CSV direction, the header is every key found in any object, in the order they first appear, and nested objects or arrays are written as JSON text inside the cell. The tool expects commas as separators; it does not auto-detect semicolons or tabs.

  • CSV to JSON and JSON to CSV in one place
  • RFC 4180 quoting handled by Papa Parse
  • Union of keys as the CSV header; nested values kept as JSON text
  • Copy output with one click
  • Runs in your browser
Read the guide: Converting CSV to JSON (and Back) Without Losing Data

Updated

How to use the CSV to JSON Converter

  1. Paste CSV, with a header row first, into the input box. Or paste a JSON array of objects.
  2. Click CSV to JSON or JSON to CSV.
  3. Check the output, then use Copy to put it on your clipboard.
  4. Use Clear All to start again.

Worked examples

Quoted commas stay in one field

Input

id,name,city
1,"Lovelace, Ada",London
2,Grace Hopper,"New York"

Output

[{"id":"1","name":"Lovelace, Ada","city":"London"},{"id":"2","name":"Grace Hopper","city":"New York"}]

A naive split on commas would give four fields on the first row. Note that id comes out as the string "1", not the number 1.

Uneven objects and nested values to CSV

Input

[{"id":1,"name":"Ada","tags":["math","code"]},{"id":2,"name":"Linus","team":"kernel"}]

Output

id,name,tags,team
1,Ada,"[""math"",""code""]",
2,Linus,,kernel

team only exists in the second object but still gets a column. The tags array is stored as JSON text, quoted and with its quotes doubled as CSV requires.

Background and insight

CSV is older than the personal computer. Comma-separated values were supported by IBM's Fortran compilers in the early 1970s, and the format spread because every spreadsheet and database could read and write it. It was not formally described until RFC 4180 in 2005, and even that document says it is documenting existing practice rather than defining a strict standard.

That history explains why CSV is full of dialects. Excel in many European locales uses semicolons because the comma is the decimal separator. Fields that contain commas or line breaks must be wrapped in double quotes, and a literal quote inside a quoted field is written as two quotes.

Going from CSV to JSON also raises the question of types. CSV has none; every value is text. Whether "007" should become the number 7 or stay a string, and whether an empty cell is an empty string or null, are decisions the consuming code has to make explicitly. This converter keeps every value as a string so nothing is lost.

Common use cases

  • Seeding a mock API

    Turn a small spreadsheet of sample records into JSON for a mock server or fixture file.

  • Opening API data in a spreadsheet

    Convert a JSON array of objects into CSV that Excel, Numbers or Google Sheets can open.

  • Quick data checks

    See a CSV export as structured objects to spot missing or misaligned columns.

  • Preparing imports

    Reshape JSON from one system into CSV for a bulk import screen that only accepts spreadsheets.

Tips and limitations

  • Header names are trimmed, so " email" and "email" become the same key, and two identical headers are rejected rather than one silently overwriting the other.
  • Cells that start with =, +, - or @ can run as formulas when the CSV is opened in Excel. Be careful exporting user-supplied text to CSV for others to open.
  • Excel adds a byte order mark to "CSV UTF-8" exports. If your first key looks odd in JSON, the invisible BOM is attached to it.
  • Leading zeros survive because values stay strings. Convert types in your own code, and keep postcodes and phone numbers as strings.
  • For tab-separated data use the TSV parser; for .xlsx files use the Excel to JSON converter.

Sources and further reading

  1. RFC 4180: Common Format and MIME Type for Comma-Separated Values (CSV) Files, IETF. The quoting rules for commas, line breaks and doubled quotes
  2. RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format, IETF. The JSON format the converter produces
  3. csv: CSV File Reading and Writing, Python Software Foundation. How real-world CSV dialects differ in delimiters and quoting

Frequently asked questions

Does the CSV converter handle commas inside quoted fields?

Yes. Quoted commas, escaped double quotes ("") and line breaks inside quoted fields are all supported, as RFC 4180 describes. An unclosed quote is reported as an error instead of being guessed at, so a broken export does not quietly produce shifted columns.

What JSON shape does JSON to CSV need?

A non-empty array of objects, such as [{"name":"Ada","role":"admin"}]. Every key found in any object becomes a column, in first-seen order, and missing values become empty cells. A single object, an array of arrays or an array of plain values is rejected.

Are CSV numbers converted to JSON numbers?

No. CSV has no types, so the converter keeps every value as a string, including "007" and "true". That avoids losing leading zeros or misreading IDs. Convert the fields you need with Number() or a schema library in your own code.

How do I convert a semicolon-separated CSV from Excel?

This tool expects commas. Re-export from your spreadsheet as CSV with commas (in Excel, "CSV UTF-8" uses the list separator from your regional settings), or replace the semicolons with commas if no field contains a semicolon or comma itself.

Is the CSV I convert uploaded to a server?

No. Parsing and conversion run locally in your browser with Papa Parse, and the data never leaves your device. That makes it suitable for customer exports or internal reports, as long as you handle the converted output with the same care.

What happens to nested objects when converting JSON to CSV?

They are written into the cell as JSON text, so {"x":1} appears as {"x":1} inside a quoted field rather than as [object Object]. If you need separate columns such as address.city, flatten the objects before converting.

Is there an in-depth guide to the CSV to JSON Converter?

Yes. “Converting CSV to JSON (and Back) Without Losing Data” covers the background, how it works, common pitfalls and worked examples. Read the full guide.