Example
sku,name,price,in_stock,zip
A-100,Desk lamp,24.99,true,02134
B-200,"Chair, ergonomic",189,false,94103
[
{
"sku": "A-100",
"name": "Desk lamp",
"price": 24.99,
"in_stock": true,
"zip": "02134"
},
{
"sku": "B-200",
"name": "Chair, ergonomic",
"price": 189,
"in_stock": false,
"zip": 94103
}
]
{"sku":"A-100","name":"Desk lamp","price":24.99,"in_stock":true,"zip":"02134"}
{"sku":"B-200","name":"Chair, ergonomic","price":189,"in_stock":false,"zip":94103}
Notice that price and in_stock became a number and a boolean, while zip
kept its leading zero as a string. A naive converter would turn 02134 into 2134.
Output formats
| Shape | Looks like | Best for |
|---|---|---|
| Array of objects | [{"sku":"A-100", ...}] | APIs, front-end apps, most tools |
| Array of arrays | [["sku","name"],["A-100","Desk lamp"]] | Compact data, charts, spreadsheets |
| JSON Lines | one object per line | Big files, streaming, BigQuery, log pipelines |
Convert CSV to JSON in code
JavaScript
// npm install papaparse
import Papa from 'papaparse';
const { data, errors } = Papa.parse(csvText, {
header: true, // use the first row as keys
skipEmptyLines: true,
dynamicTyping: true, // careful: turns "02134" into 2134
});
Python
import csv, json
with open("products.csv", newline="", encoding="utf-8-sig") as f:
rows = list(csv.DictReader(f)) # every value is a string
print(json.dumps(rows, indent=2))
The utf-8-sig encoding strips the BOM that Excel adds to UTF-8 CSV files. Without it, your first column
name starts with an invisible character. Need to inspect the data first? Use the CSV viewer.
Want types for the result? Paste the JSON into JSON to TypeScript.
Frequently asked questions
How do I convert CSV to JSON?
Paste CSV into the tool above, or drop a .csv file on it, and switch to the JSON view. By default each row becomes a JSON object keyed by the header row. Copy the result or download it as a .json file.
Will numbers in my CSV become JSON numbers?
With "Detect numbers & booleans" on, values like 42 or 3.14 become numbers and true/false become booleans. Values with leading zeros (zip codes, IDs like 007) and integers too large for JavaScript stay strings, so no data is lost. Turn the option off to keep every value as a string.
What is JSON Lines (NDJSON)?
JSON Lines puts one JSON object per line, with no surrounding array. It is ideal for large datasets and streaming because each line can be processed independently, and it is the format used by BigQuery, Elasticsearch bulk imports and many logging tools.
What if my CSV has no header row?
Uncheck "First row is header". Columns are then named column_1, column_2 and so on, or you can use the "Array of arrays" shape to get plain rows.
Is my data uploaded?
No. Parsing and conversion run entirely in your browser, so it is safe for customer lists, exports and other sensitive data.