plain/devtools home

Convert CSV to JSON

The first CSV row becomes the keys and every later row becomes one JSON object. A field in double quotes may contain commas, so "Austin, TX" stays one value.

Last reviewed 2026-11-04.

csv-jsonsampless sample · c copy

never leaves your browser

Worked example

This CSV has 2 data rows and 3 columns:

$ name,age,city
Ada,36,London
Lin,29,"Austin, TX"

becomes

[
  {
    "name": "Ada",
    "age": "36",
    "city": "London"
  },
  {
    "name": "Lin",
    "age": "29",
    "city": "Austin, TX"
  }
]

Everything is a string by default

CSV has no types, so 36 arrives as the string "36". Turn on "Numbers, true, false and empty as null" to get real types. The same data then converts to:

$ [{"name":"Ada","age":36,"active":true},{"name":"Lin","age":29,"active":null}]

Common mistakes

  • Splitting on commas with line.split(","). It breaks on quoted fields; use a real parser.
  • A semicolon-delimited export (common in European Excel) read as comma-delimited gives one column. Set the delimiter or use detect.
  • Leading zeros such as 00123 become 123 when numbers are converted. Keep them as strings if they are IDs.
  • To go the other way, see JSON to CSV.

Running this on a server

The conversion runs in your browser, so the data never leaves your machine. To run the same conversion on a server in a pipeline, the hosting guide compares small hosts.

Frequently asked questions

How do I convert CSV to JSON in JavaScript?

Use a parser that handles quotes, such as the csv-parse or papaparse packages, then JSON.stringify the rows. Do not split on commas.

Does it need a header row?

No. Without one, the output is an array of arrays.

Is my file uploaded?

No. The conversion runs locally in the page.

Sources

Related

esc
↑↓ move↵ open? all shortcuts

Keyboard shortcuts

Cmd or Ctrl shortcuts always work.
Everywhere
Everywhere
Open the command palette
CtrlK
Open the palette (outside a text field)
/
Show these shortcuts
?
Toggle light and dark theme
t
Go home
gh
Go to all tools
gt
On a tool page
On a tool page
Run the main action
Ctrl↵
Copy the output
c
Load the next sample
s
Focus the input
i
Leave a text field
Esc
Previous or next tool
[]
In the palette
In the palette
Move the selection
↑↓
Open the selected item
↵
Close
Esc