How to convert CSV to JSON

There are four practical ways to turn CSV into JSON, depending on where your data lives and how often you do it. Here's each one, shortest path first.

1. Use a converter (no code)

Fastest for a one-off file. Paste your CSV into the CSV to JSON converter, pick the delimiter, and copy the result. It runs in your browser, so nothing is uploaded — handy when the data is sensitive.

2. Python (pandas or the standard library)

With pandas, one line does it:

import pandas as pd
df = pd.read_csv("data.csv")
df.to_json("data.json", orient="records", indent=2)

Without pandas, the standard library is enough:

import csv, json

with open("data.csv", newline="") as f:
    rows = list(csv.DictReader(f))

with open("data.json", "w") as f:
    json.dump(rows, f, indent=2)

3. JavaScript (Node or browser)

Using a library such as papaparse handles quotes and edge cases for you:

import Papa from "papaparse";

const { data } = Papa.parse(csvText, { header: true, skipEmptyLines: true });
const json = JSON.stringify(data, null, 2);

4. Google Sheets

Import the CSV into Sheets, then use a script (Extensions → Apps Script) or an add-on to export the sheet as JSON. For a quick one-off, the in-browser converter above is usually faster.

Which should you use?

Tool

Open the CSV → JSON converter →

More tools