JSON and CSV both store data as text, and both are everywhere. They are good at different things, and picking the wrong one causes real problems: lost precision, ugly workarounds, or files three times larger than they need to be. Here is how to choose.
The core difference
CSV is a grid. Every row has the same columns. There is a header line and then one record per line. It is the natural shape for a spreadsheet or a database table.
JSON is a tree. Values can be objects, arrays, strings, numbers, booleans or null, nested to any depth, and records need not share the same keys. It is the natural shape for an API payload or a configuration file.
id,name,city
1,Ada,Leeds
2,Grace,Boston
[
{ "id": 1, "name": "Ada", "city": "Leeds" },
{ "id": 2, "name": "Grace", "city": "Boston" }
]
The same two records, in the two formats.
Comparison
| CSV | JSON | |
|---|---|---|
| Structure | Flat rows and columns | Nested objects and arrays |
| Data types | None; everything is text | String, number, boolean, null, object, array |
| Size for tabular data | Smaller; keys appear once | Larger; keys repeat in every record |
| Human editing | Easy in a spreadsheet | Easy in a text editor, harder for big data |
| Streaming | Trivial, line by line | Needs JSON Lines or a streaming parser |
| Standard | RFC 4180 (loosely followed) | RFC 8259, strict |
| Open in Excel | Directly | Via import or conversion |
| Schema / validation | None built in | JSON Schema |
| Comments | No | No |
Use CSV when
- The data is genuinely tabular: same fields on every record, no nesting.
- People will open it in a spreadsheet. Finance, ops and analytics teams live in Excel and Sheets.
- Size matters. CSV omits repeated key names, so a flat export is often a third to a half the size of the equivalent JSON.
- You need to stream or append. You can write a CSV one line at a time, and add rows by appending.
- You are exchanging data with databases or BI tools. Bulk loaders,
COPYin PostgreSQL and most dashboards accept CSV natively.
Use JSON when
- The data has structure. An order with line items, a user with a list of addresses, a config with sections.
- You need types.
"1"and1andtrueare different in JSON. In CSV they all look alike. - Records vary. Optional fields are simply absent in JSON. CSV forces an empty column for every possible field.
- An API or application consumes it. Every language parses JSON natively and web APIs overwhelmingly speak it.
- You need to validate. JSON Schema lets you state exactly what is permitted.
Pitfalls of each
CSV
- No types. Spreadsheets guess.
00123becomes123,3-4becomes a date, and 19-digit IDs are rounded. - No standard dialect. Delimiters can be commas, semicolons or tabs. Decimal commas in European locales collide with comma delimiters. Encoding may be UTF-8, UTF-8 with BOM, or a legacy code page.
- Quoting is easy to break. Values containing commas, quotes or line breaks must be quoted and escaped. Hand-built CSV often gets this wrong.
- No nesting. Any hierarchy must be flattened, which loses structure. See how to flatten nested JSON.
JSON
- Verbose for tables. Repeating every key in every record adds up.
- Numbers are floats in many parsers. Integers beyond 2^53 may be rounded by JavaScript.
- Strict syntax. One trailing comma or unquoted key invalidates the file. See common JSON errors and how to fix them.
- No native date type. Dates are strings by convention, usually ISO 8601.
Converting between them
JSON to CSV works well if you flatten the nesting and decide how to treat arrays. The JSON to Table tool does both and exports CSV or Excel; the process is covered in how to convert Postman JSON to CSV.
CSV to JSON is simpler, but type detection is the issue. Decide whether "42" should be the number 42, and whether empty cells become null, empty strings, or are omitted. The CSV to JSON converter detects numbers, booleans and nulls and lets you override that.
Round-tripping is not always lossless. JSON to CSV to JSON flattens nested objects into dotted keys, and the original structure does not come back by itself. Keep the original if it matters.
Third options
- JSON Lines (NDJSON). One JSON object per line. It keeps JSON’s types and flexibility while allowing streaming and appending like CSV. A good choice for logs and large exports.
- Parquet or Arrow. Columnar binary formats for large analytical datasets. Smaller and faster than either, but not human-readable.
- XLSX. If the audience is people in Excel and you care about types, formatting and multiple sheets, deliver a real workbook. See JSON to Excel.
A simple rule
Ask who or what reads it next. If it is a person in a spreadsheet or a bulk loader, use CSV. If it is a program or API, or the data has nesting or optional fields, use JSON. If it is both, keep JSON as the source of truth and generate CSV for the people who need it.