Two files, both full of data, both plain text — but data.csv opens in Excel and data.json opens in your code editor. The difference decides whether your API design, your data pipeline, or your weekend spreadsheet actually works.
What each format is
CSV (comma-separated values) is a table: rows and columns, nothing else. Every row has the same columns, and every cell is a flat value.
JSON (JavaScript Object Notation) is a tree: objects inside arrays inside objects, with no fixed shape. It’s how APIs, config files, and databases exchange structured data.
The practical differences
| CSV | JSON | |
|---|---|---|
| Structure | Flat table | Nested tree |
| Data types | Everything is text | Numbers, booleans, null, arrays, objects |
| Humans | Readable in Excel/Sheets | Readable in a text editor |
| Programs | Import/export everywhere | Native to every language |
| Size | Compact for tables | Verbose (repeats field names) |
| Edge cases | Commas/line breaks in cells need quoting rules | Handles them natively |
When to choose which
Choose CSV when the data is naturally a table — user lists, order exports, sensor readings, anything destined for a spreadsheet. CSV’s strength is that non-programmers can work with it in Excel.
Choose JSON when the data has hierarchy — a user with multiple addresses, each with a city and postcode; a config with nested options. JSON expresses relationships CSV simply can’t, and preserves types like true vs "true" and 42 vs "42".
A telltale sign you’re using the wrong one: CSV columns like phone1, phone2, phone3 — that’s a list crammed into a table. That list belongs in JSON as an array.
Converting between them
The conversion only makes sense in one direction at a time, and it’s lossy both ways:
- CSV → JSON: every row becomes an object; all values become strings. Nested data isn’t recoverable because it was never there.
- JSON → CSV: only works for JSON that’s already an array of flat objects. Nested objects get flattened or dropped.
Our CSV ↔ JSON converter does both directions instantly in your browser, and the JSON formatter tidies up the result so you can read the structure at a glance.