How to Convert CSV Data to JSON for APIs
Convert CSV to JSON instantly in your browser. Auto-detects headers and delimiters. Supports TSV. Private, no upload, no signup.
Try CSV to JSON Converter free →
The problem
You have a CSV export from a database, spreadsheet, or API and you need it as JSON — for an API request, a config file, a test fixture, or just to work with it in JavaScript. You could write a quick script, but handling quoted fields, escaped commas, and header mapping correctly takes more code than you'd think.
Most online converters either upload your file to a server or can't handle edge cases like fields with commas inside quotes, or mixed delimiters. For data that came from a production database, uploading it isn't an option.
How it works
- Paste CSV data or drag-and-drop a
.csv/.tsvfile into the input area. - The delimiter is auto-detected — comma, tab, semicolon, or pipe. Override manually if needed.
- See JSON output instantly — headers become object keys, rows become objects. Or switch to array-of-arrays mode for raw rows.
- Toggle number detection — numeric strings like
"42"can be auto-converted to actual numbers, or left as strings. - Copy or download — copy to clipboard or download as a
.jsonfile.
Your data never leaves your browser. All processing happens locally.
Why I built it
I convert CSV to JSON regularly — loading test data, transforming exports for API consumption, feeding spreadsheet data into scripts. The JSON Formatter already converts JSON to CSV, so building the reverse was a natural next step. I wanted it to handle the real-world edge cases that trip up naive parsers: quoted fields with commas, escaped quotes, mixed line endings.
Tips and reference
CSV looks simple, but parsing it correctly means handling these edge cases:
| Edge case | Example | How it's handled |
|---|---|---|
| Commas in fields | "New York, NY" | Quoted fields — commas inside quotes are not delimiters |
| Quotes in fields | "He said ""hello""" | Doubled quotes ("") represent a literal quote character |
| Newlines in fields | "Line 1\nLine 2" | Quoted fields can span multiple lines |
| Mixed line endings | CRLF vs LF | Both Windows (\r\n) and Unix (\n) endings are supported |
| Empty fields | a,,c | Empty string value (or null depending on format) |
| BOM character | \uFEFF at start | UTF-8 BOM stripped automatically |
CSV vs JSON — when to use each
CSV is ideal for flat, tabular data — spreadsheet exports, database dumps, bulk imports. Every row has the same columns. It's compact and human-readable in any text editor.
JSON is better for nested or irregular data — API responses, configuration, documents with varying fields. It supports objects, arrays, and mixed types that CSV can't represent.
This tool bridges the gap when you need to move data from a CSV-oriented system (Excel, databases, flat files) into a JSON-oriented one (APIs, JavaScript, NoSQL stores).
Built with vanilla HTML/JS. No frameworks, no backend, loads instantly.