Anyone who moves data around eventually meets the JSON vs CSV question: should this export be a JSON file or a CSV file? Pick wrong and you can spend an afternoon fighting type coercion and quote-escaping bugs. This guide lays out the trade-offs and shows how to convert between the two formats in your browser without uploading anything.
When should you use JSON vs CSV?
Use CSV for tabular data with a single, fixed schema, rows of records that all share the same columns. Use JSON for nested or hierarchical data, optional fields, mixed types, or any payload an API will read. CSV wins on file size, spreadsheet compatibility and streaming; JSON wins on structure and data types. When you need both, for example a CSV export of a JSON API response, convert with a browser-based tool like our CSV / JSON converter so nothing leaves your machine.
JSON vs CSV side by side
| Feature | JSON | CSV |
|---|---|---|
| Structure | Hierarchical (nested objects and arrays) | Flat tabular (rows and columns) |
| Data types | String, number, boolean, null, object, array | String only (interpretation is up to the reader) |
| Schema | Per-record, flexible | Fixed across all rows (one header line) |
| File size | Larger (keys repeated each record) | Smaller (keys appear once, in the header) |
| Human readability | Good with indentation | Excellent for small files in a spreadsheet |
| Spreadsheet support | Plugin or conversion required | Native everywhere |
| Streaming / line-by-line parse | Hard (need ND-JSON / JSONL) | Trivial |
| Unicode handling | UTF-8 required between systems (RFC 8259) | Encoding ambiguity is common |
| Quote / escape rules | Strict and unambiguous | RFC 4180 plus many dialects |
| Comments | Not supported (use JSON5 or JSONC if needed) | Not supported |
| Typical use case | REST API responses, config files | Spreadsheet exports, log analysis, ML datasets |
JSON vs CSV file size: why CSV is smaller
Consider 10,000 user records with five fields each. In JSON every record repeats every key:
[
{"id": 1, "name": "Ada", "email": "ada@example.com", "active": true, "score": 92.4},
{"id": 2, "name": "Bob", "email": "bob@example.com", "active": false, "score": 71.8},
...
]
That repeats "id", "name", "email", "active", "score" ten thousand times. In CSV they appear exactly once, on line one:
id,name,email,active,score
1,Ada,ada@example.com,true,92.4
2,Bob,bob@example.com,false,71.8
...
For the two sample records, minified JSON is 152 bytes and the CSV is 91 bytes, 40% smaller. Pretty-printed with two-space indentation, which is how most converters output it by default, the same JSON grows to 225 bytes. An array of arrays, with the keys written once as the first row, gets minified JSON down to 117 bytes, close to the CSV. In a generated sample of 10,000 records with the same five fields, minified JSON came to 827,831 bytes and CSV to 397,856 bytes, 52% smaller. Compression narrows the gap because repeated keys compress well: gzipped at level 9, the same files were 87,159 and 81,431 bytes, a difference of under 7%. How much you save depends on how long your key names are compared with the values.
When CSV clearly wins
- Spreadsheet handoff. Marketing, finance and operations teams work in Excel and Google Sheets, and CSV opens directly in both.
- Streaming and line-by-line processing. You can read a 50 GB CSV one row at a time without holding the whole file in memory. A JSON array has to be parsed as one structure unless you use JSONL.
- Tabular machine learning datasets. pandas, scikit-learn, R and most BI tools read CSV directly.
- Database bulk imports.
COPY ... FROMin PostgreSQL,LOAD DATA INFILEin MySQL, BigQuery and Redshift bulk loaders all accept CSV directly. - Log files for downstream analytics, which are append-only, keep a stable schema and compress well.
When JSON clearly wins
- Anything an API serves. REST and most GraphQL responses are JSON, and every mainstream language can parse it.
- Nested or hierarchical data. A user with several addresses, each with several phone numbers, flattens awkwardly into CSV but reads naturally as JSON.
- Optional or sparse fields. JSON simply omits missing keys, while CSV needs an empty cell in every column of every row, even when most fields are unused.
- Mixed types in the same field. A
valuefield that is sometimes a number, sometimes a string and sometimes null keeps those types in JSON; CSV turns all three into text. - Configuration files, because JSON is self-describing and most editors can check its syntax.
- Inter-service messaging. Webhooks, message queues and event streams commonly use JSON.
How to convert JSON to CSV and CSV to JSON in the browser
- Open our CSV / JSON converter. The conversion runs entirely in your browser, so your data never touches a server.
- Pick the direction with the CSV → JSON or JSON → CSV button; the tool doesn't detect it. Paste your data into the input box. The tool takes pasted text, not file uploads.
- Set the options. For CSV → JSON, choose the delimiter (comma, semicolon, tab or pipe), whether the first row is a header, and Array of Objects or Array of Arrays. For JSON → CSV, the input must be an array of objects or arrays; the header row lists every key found in any object, and missing values become empty cells.
- Check nested fields. JSON → CSV doesn't flatten them: a nested object or array is written into one cell as JSON text, so
{"address": {"city": "London"}}becomes"{""city"":""London""}". - Click Convert, then Copy. Validate the JSON output with the JSON formatter if you want to inspect the structure before using it elsewhere. In CSV → JSON mode the converter turns number-like cells into numbers, so leading zeros disappear; converting CSV to JSON without uploading covers those rules.
Binary data such as images or PDFs has to be Base64-encoded before it can sit inside a JSON string; our Base64 tool does that.
CSV gotchas that bite everyone
CSV looks simple, but it has plenty of edge cases. RFC 4180 is an informational document that records the format "followed by most implementations", not a strict standard, so programs disagree. The big ones:
- Delimiter choice. Spreadsheets in countries that use the comma as the decimal separator, such as Germany and France, often export with semicolons. Tab is safer for international data.
- Quoting rules. A field containing a comma must be quoted, and a quote inside a quoted field is escaped by doubling it:
"He said ""hi""". Inconsistent quoting causes many CSV bugs. - Line endings. RFC 4180 specifies CRLF, Unix tools write LF. Most parsers handle both; some legacy ones don't.
- BOM (byte order mark). Files saved as "UTF-8 with BOM" start with the bytes EF BB BF, and some parsers read them as part of the first column name.
- Trailing newlines. Some parsers create a phantom empty row from a final newline. Strip it on read.
- Leading zeros and big integers. Microsoft says Excel removes leading zeros and rounds digits after the 15th to zero, so a SKU like
007123becomes7123and an ID like9007199254740993becomes 9007199254740990, displayed in scientific notation. Import those columns as text. - Date formats. 03/04/2026 is March 4 in the US and April 3 in the UK and most of Europe. Use ISO 8601 (
2026-03-04). - Boolean coercion.
TRUE,true,1andyesmean different things to different parsers.
JSON gotchas that bite slightly fewer people
If the syntax itself is new to you, what JSON is and how it is written covers the six value types first.
- Integer precision. JSON itself sets no limit, but many parsers, JavaScript's included, read numbers as IEEE 754 doubles, and RFC 8259 only promises exact agreement for integers between -(2^53)+1 and 2^53-1. In JavaScript,
JSON.parse("9007199254740993")returns 9007199254740992. Send large IDs, such as some database or snowflake IDs, as strings. - No trailing commas.
[1, 2, 3,]is invalid JSON; the most common JSON formatting errors lists the exact messages parsers give for this and similar slips. Use JSON5 if you need human-edited configs that tolerate trailing commas. - No comments. Same reason; use JSON5 or JSONC for configuration files.
- UTF-16 surrogate pairs. Some serializers escape emoji and other characters outside the Basic Multilingual Plane, so the grinning face emoji (U+1F600) appears as
"\ud83d\ude00"(Python's default output) instead of the literal character. Most parsers handle both forms, but some legacy ones don't. - Date types do not exist. Dates must be strings (use ISO 8601) or numbers (Unix timestamps). Pick one and document it.
- Order is not guaranteed. RFC 8259 defines an object as unordered and notes that parsers differ in whether they expose member order. JavaScript, for one, moves integer-like keys to the front:
{"b":1,"2":2,"a":3}comes back with its keys in the order 2, b, a.
What about JSONL / NDJSON?
JSON Lines (also called NDJSON) is JSON's answer to streaming. One JSON object per line, separated by newlines. No outer array, no commas between records:
{"id": 1, "name": "Ada"}
{"id": 2, "name": "Bob"}
{"id": 3, "name": "Cris"}
You get JSON's structure with CSV's line-by-line streaming. Many data tools load it directly; BigQuery, for example, requires JSON data to be newline-delimited. For multi-gigabyte JSON exports, JSONL is usually the right choice.
A note on Parquet, Arrow, and Avro
For analytical workloads beyond a few hundred megabytes, columnar formats like Parquet and in-memory formats like Apache Arrow beat both CSV and JSON: files are typically much smaller than CSV, scans can read only the columns you need, and the schema and types are preserved. Use them for data-warehouse pipelines and ML feature stores. Stick to JSON or CSV for human-readable, ad-hoc, and API-facing data.
Frequently asked questions
Is JSON faster to parse than CSV?
Not necessarily; it depends more on the parser and the data than on the format. CSV's simpler grammar suits row-by-row streaming, while JSON parsers in most languages are well optimized for loading a whole document. For very large files, JSONL lets you stream JSON one record at a time.
Can I open a JSON file in Excel?
Yes. Excel's Get Data feature uses the Power Query JSON connector, which flattens JSON into a table automatically, and you can adjust the result in the Power Query editor. If your Excel version doesn't have it, convert the JSON to CSV first with a browser-based converter.
Why does my CSV show scientific notation in Excel?
Excel auto-types numeric columns, so long IDs and SKUs are shown in scientific notation and lose every digit after the 15th. Instead of double-clicking the file, import it with Data > From Text/CSV, choose Transform Data, and set those columns to Text before loading.
How do I represent nested data in CSV?
You don't, cleanly. The two workarounds are flattening with dot notation (user.address.city) or denormalizing into multiple rows (one row per nested item, repeating the parent fields). Both work, both have trade-offs. If the nesting is essential, switch to JSON or JSONL.
Is JSON more secure than CSV?
Both formats are inert text; neither executes code by itself. The risk is in the parser: CSV injection (a cell starting with = can run a formula when opened in Excel) and JSON deserialization vulnerabilities in poorly written libraries are both real. Sanitize inputs and use up-to-date parsers regardless of format.
Should I gzip JSON or CSV for storage?
Both compress well. In the 10,000-record sample above, gzip cut the JSON by 89.5% and the CSV by 79.5%, leaving the CSV 6.6% smaller. Your ratio will depend on the data. For warehouse-scale storage, columnar formats such as Parquet beat both.
JSON vs CSV: which is better?
CSV is better for a fixed set of columns that someone may open in a spreadsheet. JSON is better for nested records, optional fields, typed values and anything an API sends, with JSONL for files too big to load in one go, and Parquet for large analytical datasets. When you need the other format, our converter turns CSV to JSON and back in your browser; check number-like columns such as ZIP codes in the result, because CSV to JSON conversion turns 02134 into 2134.
Sources: RFC 8259 (JSON), RFC 4180 (CSV), ECMA-404 (JSON data interchange syntax), BigQuery and Microsoft Excel documentation.