CSV to JSON Converter
Convert CSV data to JSON format with type inference, custom delimiters, and bidirectional conversion support.
Why I Built This CSV Converter
CSV looks simple until it isn't. I've broken three production data imports learning this lesson - escaped quotes, BOM characters, European semicolon delimiters, the works. I built this converter to handle the edge cases I kept running into. Paste your CSV, get clean JSON with proper types. Or go the other way when you need to feed data into Excel for a non-technical colleague.
What This Tool Does
- Bidirectional Conversion - CSV to JSON or JSON to CSV, whichever you need
- Custom Delimiters - Comma, semicolon (looking at you, European exports), tab, pipe
- Header Detection - Use first row as field names or fall back to indices
- Type Inference - Automatically detects numbers, booleans, and nulls (toggle it off for ZIP codes!)
- Preview Table - See your data before committing to the conversion
- Download - Save as .json or .csv file directly
I often use this with the JSON Formatter to beautify the output, and the YAML Converter when I need to chain format transformations.
The CSV Gotchas I've Learned the Hard Way
CSV (Comma-Separated Values) seems straightforward until you hit real-world data. Here's what I've learned to watch out for:
- Excel exports with semicolons (regional settings strike again)
- Quoted fields with commas inside them
- BOM characters at the start of UTF-8 files
- Numbers that should stay as strings (ZIP codes, product IDs)
- Line breaks inside quoted fields
The format is described in RFC 4180, though many real-world implementations differ.
CSV vs JSON: My Take
I use CSV when: I need to share data with non-developers, import/export from spreadsheets, or work with simple flat data. Nothing beats CSV for "here's the data, open it in Excel."
I use JSON when: I need nested structures, type safety, API payloads, or config files. JSON is what your code actually wants to work with.
CSV to JSON in Different Languages
When the browser tool won't cut it — batch processing, server-side pipelines, or files too big for the browser — here's how I handle CSV in code.
Python with pandas
pandas is overkill for simple conversions, but once your data needs filtering, aggregation, or type handling, nothing beats it. I reach for it whenever a CSV has more than a few thousand rows.
import pandas as pd
import json
# Read CSV with options
df = pd.read_csv("data.csv", delimiter=",", encoding="utf-8")
# Convert to JSON (records orientation = array of objects)
json_data = df.to_json(orient="records", indent=2)
# Or write directly to file
df.to_json("output.json", orient="records", indent=2)Node.js with csv-parse
For Node.js, csv-parse handles streaming large files without loading everything into memory. I use this in ETL scripts that run as cron jobs.
import { parse } from 'csv-parse/sync';
import { readFileSync, writeFileSync } from 'fs';
const csv = readFileSync('data.csv', 'utf-8');
const records = parse(csv, {
columns: true, // use first row as keys
skip_empty_lines: true,
cast: true, // auto-detect types
});
writeFileSync('output.json', JSON.stringify(records, null, 2));PostgreSQL COPY FROM CSV
When your CSV needs to go straight into a database, PostgreSQL's COPY command is the fastest path. Skip the JSON middleman entirely.
-- Import CSV directly into a table COPY users(name, email, created_at) FROM '/path/to/data.csv' WITH (FORMAT csv, HEADER true, DELIMITER ','); -- Export query results as CSV COPY (SELECT * FROM users WHERE active = true) TO '/path/to/export.csv' WITH (FORMAT csv, HEADER true);
jq for Command-Line Conversion
For quick one-off conversions in the terminal, jq paired withcsvtool or miller gets the job done without writing code.
# Using miller (mlr) - my favorite CLI tool for this mlr --icsv --ojson cat data.csv > output.json # Reverse: JSON to CSV mlr --ijson --ocsv cat data.json > output.csv
Related Articles
- CSV Processing: Everything I Learned After Breaking 3 Data Imports
- CSV to JSON Converter: Complete Guide for Developers
Frequently Asked Questions
Is my CSV data secure?
Absolutely. Everything runs in your browser - I don't see your data, I don't store your data, I don't want your data. This was a non-negotiable when I built CodeUtil.
My CSV uses semicolons, not commas. What now?
Classic European export issue! Just pick semicolon from the delimiter dropdown. I added this after receiving too many CSVs from German colleagues that wouldn't parse.
How do I keep ZIP codes as strings?
Turn off type inference. Otherwise "01234" becomes 1234 and suddenly half of Massachusetts has invalid ZIP codes. Ask me how I know.
Can I convert large CSV files?
Yes, though your browser does the heavy lifting. Files over 10MB might take a moment. For truly massive datasets, I'd use Python with pandas - but for quick conversions, this handles most real-world files just fine.