There are three practical ways to convert CSV to JSON, and the right choice depends on whether you are doing a quick one-off, writing a data script, or building it into a pipeline. Here is each method, step by step, with the exact code you need.
Best for: one-off conversions, non-developers, sensitive data you do not want to upload anywhere.
The entire round trip is under 15 seconds. The data never leaves your browser — there is no server upload, no processing delay, no account required. For files with personal information (lead lists, customer exports, employee data), this is the safest option.
Best for: data analysts, repeated conversions, files that need preprocessing, automation scripts.
Python ships with everything you need — no pip install required:
import csv, json
with open('data.csv', encoding='utf-8-sig') as f:
rows = list(csv.DictReader(f))
with open('data.json', 'w') as f:
json.dump(rows, f, indent=2)
What each line does:
Want to filter rows or transform values during conversion? Add logic between reading and writing:
# Keep only rows where plan == 'Pro' and convert price to float
rows = [
{**row, 'price': float(row['price'])}
for row in csv.DictReader(f)
if row['plan'] == 'Pro'
]
Best for: backend services, CI/CD pipelines, serverless functions, npm-based projects.
Install the csvtojson package:
npm install csvtojson
Convert a file:
const csvtojson = require('csvtojson');
csvtojson()
.fromFile('./data.csv')
.then(json => {
require('fs').writeFileSync(
'data.json',
JSON.stringify(json, null, 2)
);
console.log(json.length + ' rows converted');
});
The csvtojson package handles streaming (critical for large files), custom delimiters, header renaming, column selection, and automatic type detection. It processes rows as a stream rather than loading the entire file into memory.
| Situation | Best Method | Why |
|---|---|---|
| Quick one-off conversion | Browser tool | Zero setup, 15 seconds, done |
| Converting a HubSpot/Salesforce export | Browser tool | Likely contains PII — keep it local |
| Daily report automation | Python script | Schedule with cron, full control over transforms |
| Data analysis in Jupyter | Python script | DictReader integrates with pandas workflows |
| API endpoint that accepts CSV uploads | Node.js csvtojson | Stream processing, production-grade parsing |
| CI/CD build step | Node.js csvtojson | npm ecosystem, async/await, easy integration |
| Converting on a machine with no dev tools | Browser tool | Only needs a web browser |
| 50MB+ file with memory constraints | Node.js or Python | Streaming prevents memory overflow |
These trip up even experienced developers:
"\ufeffname" instead of "name", you have a BOM issue. Python fix: encoding='utf-8-sig'. Browser tools strip it automatically.Once you have your JSON, these tools help you work with it:
Skip the setup — paste CSV, get JSON, done in 15 seconds.
Open CSV to JSON Converter