CSV stores data as flat rows of text separated by commas, while JSON stores data as typed, nested objects and arrays. Choose CSV for tables that people open in spreadsheets or load into databases, and JSON for data that code exchanges through APIs and configuration files.
The rest of this guide compares the two formats side by side, shows the same data in each, and explains when converting from one to the other makes sense.
On this page
Key takeaways
- CSV is flat and untyped; JSON supports types, nesting and arrays.
- CSV files are usually smaller for large tables because keys are not repeated on every row.
- Spreadsheets and databases prefer CSV; web APIs and JavaScript prefer JSON.
- Flat tables convert cleanly in both directions; nested JSON needs flattening to become CSV.
Steps shown in the video
- Click Choose CSV Files and select your CSV file
- Your file is listed with its size
- Click Convert to JSON
- Download your .json file
The same data in CSV and JSON
id,name,city,active
1,Ana,Lisbon,true
2,Ben,Leeds,false[
{ "id": 1, "name": "Ana", "city": "Lisbon", "active": true },
{ "id": 2, "name": "Ben", "city": "Leeds", "active": false }
]The CSV names each column once. The JSON repeats the keys in every object but records that id is a number and active is a boolean.
CSV vs JSON: side-by-side comparison
| CSV | JSON | |
|---|---|---|
| Structure | Flat table of rows and columns | Objects and arrays, nested to any depth |
| Data types | Text only | String, number, boolean, null, object, array |
| Standard | RFC 4180 (informal) | RFC 8259 |
| File size for big tables | Smaller | Larger, keys repeat on every row |
| Opens in spreadsheets | Yes, directly | Needs converting first |
| Used by web APIs | Rarely | Almost always |
| Human readability | Easy for tables | Easy for nested records |
| Schema | Header row only | Optional, via JSON Schema |
When is CSV the better choice?
- Spreadsheet work. Analysts can open a CSV in Excel or Google Sheets immediately. Converting it with CSV to Excel avoids Excel's guesses about zeros and dates.
- Bulk imports into databases, CRMs and online shops.
- Very large flat datasets, where repeating keys would inflate the file.
- Data shared with non-developers, who rarely want to read braces and quotes.
When is JSON the better choice?
- APIs and web apps. JavaScript reads JSON natively and every backend language has a parser.
- Nested data, such as an order with several line items or a user with a list of addresses.
- Typed values, when your code must know that a value is a number, a boolean or missing.
- Configuration and content files that developers edit and review.
Converting between CSV and JSON
Flat tables convert cleanly in both directions. CSV to JSON turns each row into an object with typed values, and JSON to CSV does the reverse, writing any nested objects into a single cell as JSON text.
For details of how values are typed, read how CSV headers, numbers and empty cells become JSON.
How much bigger is JSON for the same data?
Because JSON repeats every key in every record, the overhead grows with the number of rows. In the example above, the CSV names the columns once in a single header line, while the JSON spells out "id", "name", "city" and "active" again for every row. With ten columns and 100,000 rows, those repeated keys can easily double the file size compared with CSV.
Compression narrows the gap a lot, since repeated keys compress very well, which is why APIs happily send JSON over gzip. For files you store or email uncompressed, CSV stays the leaner choice for big, flat tables.
CSV vs JSON: FAQ
Is JSON better than CSV?
Neither is better in general. CSV suits flat tables and spreadsheets; JSON suits typed and nested data used by code and APIs.
Which is smaller, CSV or JSON?
CSV, for large flat tables, because JSON repeats every key in every record.
Can Excel open JSON files?
Excel can import JSON through Power Query, but converting the JSON to CSV or XLSX first is usually quicker.
Can CSV store nested data?
Not directly. Nested values have to be flattened into extra columns or stored as text in a single cell.
How do I convert CSV to JSON?
Use a CSV to JSON converter. The header row becomes the keys and each row becomes one object in a JSON array.
Pick the format your next step needs
Use CSV when people and spreadsheets come next, and JSON when code and APIs come next. Because flat data converts cleanly both ways, you can keep each step of your workflow in the format that suits it.