# CSV vs JSON: Size, Types and Speed, Measured

> CSV vs JSON on the same 100 real rows: 14,376 bytes against 30,053, what happens to numbers and empty values, appending, JSON Lines and pandas load times.

[Home](https://quanticdata.io/) / [Blog](https://quanticdata.io/blog/) / CSV vs JSON: Size, Types and Speed, Measured

# CSV vs JSON: file size, data types and speed on the same 100 real rows

Web scraping · Nov 20, 2026 · 8 min read · By [Aldo Morese](https://quanticdata.io/about/), founder of QuanticData

![The same 100 real rows of market data written as CSV and as JSON on 20 November 2026: 14,376 bytes as CSV and 30,053 bytes as JSON, because JSON repeats the 13 column names in every row; the card shows what the Python readers returned for one cell: the text 58828 from CSV and the number 58828 from JSON, and that an empty CSV cell stands for null.](https://quanticdata.io/blog/csv-vs-json/hero.webp?v=20261120h)

On this page

- [CSV vs JSON at a glance](https://quanticdata.io/blog/csv-vs-json/#csv-vs-json-at-a-glance)
- [The same rows as CSV and as JSON](https://quanticdata.io/blog/csv-vs-json/#the-same-rows-as-csv-and-as-json)
- [CSV vs JSON file size: 14,376 bytes against 30,053](https://quanticdata.io/blog/csv-vs-json/#csv-vs-json-file-size-14-376-bytes-against-30-053)
- [Data types: what each parser gives back](https://quanticdata.io/blog/csv-vs-json/#data-types-what-each-parser-gives-back)
- [CSV vs JSON performance in Python](https://quanticdata.io/blog/csv-vs-json/#csv-vs-json-performance-in-python)
- [Appending rows, and where JSON Lines fits](https://quanticdata.io/blog/csv-vs-json/#appending-rows-and-where-json-lines-fits)
- [Nested data: where CSV stops](https://quanticdata.io/blog/csv-vs-json/#nested-data-where-csv-stops)
- [CSV or JSON: which to use](https://quanticdata.io/blog/csv-vs-json/#csv-or-json-which-to-use)

CSV is a table written as text: one header line, then one line per row, values separated by commas. JSON is a tree of typed values: objects, lists, strings, numbers, booleans and null. CSV is smaller and opens in any spreadsheet; JSON keeps data types and nested fields. Use CSV for flat tables and JSON for anything with structure.

**Run it on the free credit.** Every QuanticData account gets $2 of free API usage per month.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-lead&utm_content=csv-vs-json) · [Explore Web Scraping API](https://quanticdata.io/web-scraping-api/)

We measured the difference on real data. On 20 November 2026 we pulled 100 rows of market data, wrote the same rows as CSV, JSON and JSON Lines, and ran each file through Python's readers and pandas. The output below is from that run.

## CSV vs JSON at a glance

| Question | CSV | JSON |
| --- | --- | --- |
| Size of our 100 rows | 14,376 bytes | 30,053 bytes |
| After gzip | 6,331 bytes | 7,375 bytes |
| Shape | Rows and columns only | Any nesting of objects and lists |
| Data types | Every cell is text | String, number, boolean, null |
| Missing value | An empty cell | `null` |
| Column names | Once, in the header | In every record |
| Add a row to an existing file | Append one line | Rewrite the file, or use JSON Lines |
| Opens in | Spreadsheets, databases, pandas | Code, APIs, document databases, pandas |

## The same rows as CSV and as JSON

The rows come from our [crypto market data collector](https://quanticdata.io/collectors/crypto-market-data-api/): the 100 largest coins by market cap at 18:16 UTC, with 13 columns kept (rank, id, symbol, name, price, market cap, volume, 24-hour change, circulating supply, maximum supply, all-time high, its date, and the update time). The first two lines of the CSV file:

```
rank,id,symbol,name,price,market_cap,volume_24h,change_24h_pct,circulating_supply,max_supply,ath,ath_date,last_updated
1,bitcoin,BTC,Bitcoin,58828,1183195111322,48110085084,-6.15,20114850,21000000,126080,2025-10-06T10:57:42.000Z,2026-11-20T18:15:55.000Z
```

The same row in JSON:

```json
{"rank":1,"id":"bitcoin","symbol":"BTC","name":"Bitcoin","price":58828,"market_cap":1183195111322,
 "volume_24h":48110085084,"change_24h_pct":-6.15,"circulating_supply":20114850,"max_supply":21000000,
 "ath":126080,"ath_date":"2025-10-06T10:57:42.000Z","last_updated":"2026-11-20T18:15:55.000Z"}
```

The CSV line carries only values; the meaning of each position is in the header. The JSON record names every value and marks which ones are text (in quotes) and which are numbers.

## CSV vs JSON file size: 14,376 bytes against 30,053

```
file                    bytes    gzip
coins.csv              14,376   6,331
coins.json             30,053   7,375
coins.jsonl            30,052   7,374
coins.pretty.json      38,454   7,532
rows 100 columns 13 | key names repeated in JSON: 14500 bytes
```

- **The JSON file was 2.1 times the size of the CSV file.** Almost all of the difference is the column names: written with their quotes and colons in every one of the 100 records, they take 14,500 bytes. The CSV header spends 120 bytes on the same names, once.
- **Gzip shrinks the gap to 16%.** Repeated key names are exactly what compression removes: 7,375 bytes against 6,331. If the file travels over HTTP or sits in compressed storage, the size argument for CSV is much weaker than the raw numbers suggest.
- **Indented JSON** for people to read was 38,454 bytes, 2.7 times the CSV.

The ratio depends on the data. Short values with long column names, as here, favour CSV the most; rows with long text fields would bring the two files closer.

## Data types: what each parser gives back

This is the difference that causes real bugs. We read both files back with Python's standard library and printed the Ethereum row, which has no maximum supply:

```python
import csv, json
c0 = list(csv.DictReader(open("coins.csv", newline="", encoding="utf-8")))
j0 = json.load(open("coins.json", encoding="utf-8"))

rank         csv str   '2'                          json int       2
price        csv str   '1625.67'                    json float     1625.67
market_cap   csv str   '198688114236'               json int       198688114236
max_supply   csv str   ''                           json NoneType  None
ath_date     csv str   '2025-08-24T11:21:03.000Z'   json str       '2025-08-24T11:21:03.000Z'
```

Every CSV cell came back as a string. JSON returned an integer, a float and `None`. What that means in practice, from the same run, multiplying the first price by 2:

```
csv price * 2  ->  '5882858828'
json price * 2 ->  117656
```

The CSV value "58828" was repeated, not doubled, because it is text. The missing value is the second trap: 49 of the 100 coins have no maximum supply. JSON says so with `null`; in CSV those 49 cells are empty strings, and an empty string cannot be told apart from a value that really is empty text. Neither format has a date type: `ath_date` is a string in both.

pandas guesses the types back when it reads CSV, and in this run it guessed the same as it got from JSON:

```
--- pandas dtypes (read_csv | read_json)
rank         int64      | int64
price        float64    | float64
market_cap   int64      | int64
max_supply   float64    | float64
ath_date     str        | str
shape (100, 13) (100, 13) | total market cap equal: True 2054290063883
```

Both frames had 100 rows and 13 columns and the same total. The guess is made from the values, though: `max_supply` became a float column because of the 49 empty cells, in both readers. Cleaning that up is covered in [data wrangling in Python](https://quanticdata.io/blog/data-wrangling-python/).

**Try it on your own targets.** Every QuanticData account gets $2 of free API usage per month.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-inline&utm_content=csv-vs-json) · [Explore Web Scraping API](https://quanticdata.io/web-scraping-api/)

## CSV vs JSON performance in Python

Each reader ran 300 times on the same 100 rows (the pandas readers 100 times); the figure is the median in milliseconds:

```
python 3.12.10 pandas 3.0.3 (median of 300 runs, ms)
csv.DictReader   0.172
json.loads       0.137
json lines       0.241
pandas.read_csv  0.585
pandas.read_json 1.954
```

| Reader | File | Median | Result |
| --- | --- | --- | --- |
| `json.loads` | coins.json, 30,053 bytes | 0.137 ms | List of dicts, typed |
| `csv.DictReader` | coins.csv, 14,376 bytes | 0.172 ms | List of dicts, all strings |
| One `json.loads` per line | coins.jsonl | 0.241 ms | List of dicts, typed |
| `pandas.read_csv` | coins.csv | 0.585 ms | DataFrame |
| `pandas.read_json` | coins.json | 1.954 ms | DataFrame |

With the standard library, the JSON file parsed slightly faster even though it is twice the size, and it arrived typed. Into a pandas DataFrame, CSV loaded 3.3 times faster than JSON. So "which is faster" depends on where the data is going: plain Python objects favoured JSON here, a DataFrame favoured CSV. This is one run on one PC with 100 rows; on files of millions of rows, measure your own.

## Appending rows, and where JSON Lines fits

A scraper that runs for hours adds rows as it goes. We appended one row to each file; its name contained a comma and quotes on purpose:

```
csv   appended 157 bytes; last line: 101,example,EXM,"Example, ""quoted"" coin",58828,...
jsonl appended 312 bytes; lines now 101
json  appended to the array file -> Extra data: line 1 column 30054 (char 30053)
csv   read back name: Example, "quoted" coin | rows 101
```

- **CSV:** one more line, and the file is still valid. The `csv` module put the name in quotes and doubled the inner quotes, and read it back intact. Write CSV with a library, never by joining strings with commas.
- **JSON array:** a record written after the closing bracket made the file unreadable ("Extra data"). To add a row to a JSON array you load it, add the row and write the whole file again.
- **JSON Lines** (`.jsonl`): one JSON object per line. It appends like CSV and keeps types and nesting like JSON; our file was 30,052 bytes, one byte less than the array. It is the usual format for scraper output, logs and LLM training files for that reason.

## Nested data: where CSV stops

CSV has no way to put a list or an object in a cell. We wrote a record with a list and a nested object to CSV to see what happens:

```
name,keywords,links
parse5,"['html', 'parser', 'html5']",{'homepage': 'https://parse5.js.org'}
read back keywords: str "['html', 'parser', 'html5']"
```

Python wrote its own text form of the list into the cell, and reading it back gave a string, not a list. The working approach is to flatten on purpose before writing: `pandas.json_normalize` turned the nested object into a `links.homepage` column, and we joined the list with a separator:

```
json_normalize columns: ['name', 'keywords', 'links.homepage']
name,keywords,links.homepage
parse5,html|parser|html5,https://parse5.js.org
```

That works for one level. A record with a list of objects, such as a product with several offers, needs either one row per offer or a second file, and at that point JSON is the simpler format.

## CSV or JSON: which to use

| Your case | Use | Why, from the run above |
| --- | --- | --- |
| A flat table for a spreadsheet, a database import or pandas | CSV | Half the bytes, and the fastest DataFrame load (0.585 ms) |
| Records with lists or nested objects | JSON | CSV turned the list into text |
| Types and missing values must survive | JSON | Numbers stayed numbers, `null` stayed `null` |
| Output of a long scraping job, logs | JSON Lines | Appends one line at a time, keeps types |
| An API response | JSON | It is what clients expect; see [parsing JSON in Python](https://quanticdata.io/blog/parse-json-python/) |

You can also keep both: collect as JSON, which loses nothing, and export a CSV view when someone needs a spreadsheet. Our collectors work that way: a run returns JSON, and the same rows can be fetched as CSV text. For HTML tables that should end up as CSV, see [scraping a table from a website with Python](https://quanticdata.io/blog/scrape-table-from-website-python/); for the other common comparison, [JSON vs XML](https://quanticdata.io/blog/json-vs-xml/); for pages that are not data yet, the [Web Scraping API](https://quanticdata.io/web-scraping-api/) returns them as structured JSON.

### Sources & further reading

- [RFC 4180: Common Format and MIME Type for Comma-Separated Values (CSV) Files](https://www.rfc-editor.org/rfc/rfc4180)
- [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format](https://www.rfc-editor.org/rfc/rfc8259)
- [JSON Lines: documentation of the format](https://jsonlines.org/)
- [Python documentation: csv](https://docs.python.org/3/library/csv.html)
- [pandas documentation: IO tools (read_csv, read_json)](https://pandas.pydata.org/docs/user_guide/io.html)

## FAQ

Quick answers on csv vs json.

[Something else? Ask us](mailto:hello@quanticdata.io)

### What is the difference between CSV and JSON?

CSV stores a flat table as text: a header line and one line per row, every cell a string. JSON stores a tree of typed values: objects, lists, strings, numbers, booleans and null. CSV is smaller; JSON keeps types and nested fields.

### Is CSV smaller than JSON?

For our 100 rows of 13 columns, yes: 14,376 bytes of CSV against 30,053 bytes of JSON, because JSON repeats the column names in every record. After gzip the files were 6,331 and 7,375 bytes, a 16% difference.

### Is CSV faster than JSON?

It depended on the reader in our run. With Python's standard library, `json.loads` took 0.137 ms and `csv.DictReader` 0.172 ms. Loading into pandas, `read_csv` took 0.585 ms and `read_json` 1.954 ms.

### What is JSON Lines (JSONL)?

A file with one JSON object per line. A new record is appended as a new line, as in CSV, and each record keeps its types and nesting, as in JSON. In our test the JSON Lines file was 30,052 bytes and stayed valid after an append.

### Does CSV have data types?

No. Python's `csv` module returned every cell as a string in our test, including the price "58828" and the empty cells of the 49 rows without a maximum supply. pandas infers types from the values when it reads the file.

### Can CSV store nested data?

Not directly. A list written to a CSV cell came back as the string "['html', 'parser', 'html5']" in our test. Flatten first, for example with `pandas.json_normalize`, or keep the data in JSON.

## Collect once as JSON, export as CSV when you need a table

Collectors return typed JSON records from public pages, with a CSV export of the same rows.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-end&utm_content=csv-vs-json) · [Explore Web Scraping API](https://quanticdata.io/web-scraping-api/)

## Related reading

- [Web Scraping Project Ideas, Started for Real](https://quanticdata.io/blog/web-scraping-project-ideas/): Web scraping · Five web scraping project ideas, each one started for real on 20 November 2026: a price tracker, a library release dashboard, a question analysis, an open-source landscape and a topic timeline, with the code, the first run and what to build next.
- [Retry-After Header: Read It, Wait, Retry](https://quanticdata.io/blog/retry-after-header/): Web scraping · Retry-After tells a client how long to wait before the next request, as a number of seconds or as an HTTP date. Below: both formats, a Python and a Node helper we ran against a real 429 on 20 November 2026 (each waited 10 seconds and then got 200), the rate-limit headers of the QuanticData API, and how one batch job replaced 20 calls.
- [How to Use an API Key: curl, Python and JS](https://quanticdata.io/blog/how-to-use-an-api-key/): Web scraping · An API key is a secret string you send with every request so the service knows which account is calling. Nothing is installed: you add one header. Below: the same call in curl, Python, JavaScript and PowerShell, run on 20 November 2026 against the QuanticData API, the exact 401 messages for the usual mistakes, and how to keep the key out of your code.

---

Source: https://quanticdata.io/blog/csv-vs-json/ · Site index for AI: https://quanticdata.io/llms.txt
