Paste your CSV below to convert it to JSON:
Loading...
How CSV to JSON Conversion Works
This tool converts CSV (Comma-Separated Values) data into a JSON array of objects. Each row becomes an object, and each column header becomes a property name. It automatically detects numbers, booleans, and null values.
Example Conversion
Input CSV:
name,email,age,active
Alice,alice@example.com,30,true
Bob,bob@example.com,25,falseOutput JSON:
[
{
"name": "Alice",
"email": "alice@example.com",
"age": 30,
"active": true
},
{
"name": "Bob",
"email": "bob@example.com",
"age": 25,
"active": false
}
]Automatic Type Detection
The converter automatically parses:
| CSV Value | JSON Type |
|---|---|
123, 45.67 | Number |
true, false | Boolean |
null | Null |
| Everything else | String |
Handling Special Cases
Quoted Fields
Fields containing commas or newlines should be wrapped in double quotes:
name,description
"Acme, Inc.","A company that makes ""everything"""No Header Row
If your CSV doesn't have headers, uncheck "First row is headers" and columns will be named column1, column2, etc.
Different Delimiters
Not all CSV files use commas. European systems often use semicolons because comma is the decimal separator. Select the appropriate delimiter from the dropdown.
Common Use Cases
- API payload preparation โ Convert spreadsheet data to JSON for API requests
- Database seeding โ Transform CSV exports into JSON for MongoDB or other document databases
- Configuration files โ Convert tabular config data to JSON format
- Data transformation โ Intermediate step in ETL pipelines
Programmatic Conversion
JavaScript
function csvToJson(csv) {
const lines = csv.trim().split('\n');
const headers = lines[0].split(',');
return lines.slice(1).map(line => {
const values = line.split(',');
return headers.reduce((obj, header, i) => {
obj[header] = values[i];
return obj;
}, {});
});
}Python
import csv
import json
def csv_to_json(csv_string):
reader = csv.DictReader(csv_string.splitlines())
return json.dumps(list(reader), indent=2)Pro Tips
- ๐ก Clean your data first โ Remove empty rows and fix inconsistent quoting before converting
- ๐ก Check for BOM โ Excel sometimes adds a byte-order mark that can corrupt the first header
- ๐ก Validate after โ Use the JSON Validator to ensure your output is valid
Related Tools
- JSON to CSV โ Convert JSON back to CSV
- Excel to JSON โ Convert Excel files directly
- JSON Validator โ Validate your JSON output
- JSON Schema Validator โ Validate structure