Open Data Manual › Practical guides › CSV vs JSON: Choosing a Format for Open Data
Almost every open data publisher ends up asking the same question: should a dataset go out as a CSV file, as JSON, or both? The two formats are both open, text-based and supported by every programming language, so the choice is less about right and wrong than about the shape of the data and who will use it. This guide sets out how each format works, where each one causes trouble, and a practical rule for deciding. It builds on the short format descriptions in the manual's File Formats appendix.
Publish CSV when the data is a single flat table (rows of records, the same columns in every row) and a large share of your users will open it in a spreadsheet. Publish JSON when records are nested or vary in structure, or when the data is served through an API to developers. If you run a data portal or an API, offering both for the same dataset is common and costs little once the export is automated.
CSV (comma-separated values) stores a table as plain text: one record per line, fields separated by commas. The closest thing to a specification is RFC 4180, published in October 2005. It is an Informational RFC: it documents the format most software already used and registers the text/csv media type, rather than laying down a binding standard. Its main rules are simple:
"").What CSV does not carry is just as important. There are no data types, so a reader cannot tell whether 01234 is a number or a code with a leading zero, or whether 03/04/2026 is 3 April or 4 March. There is no standard way to say which character encoding or separator is used, and many tools in continental Europe write semicolons instead of commas. All of that context has to be supplied separately.
JSON (JavaScript Object Notation) represents data as objects (named fields), arrays (ordered lists), strings, numbers, booleans and null. It is defined by RFC 8259 (December 2017) and the matching ECMA-404 standard. RFC 8259 requires JSON exchanged between systems outside a closed ecosystem to be encoded in UTF-8, which removes one of CSV's most common problems.
Because JSON can nest, one record can hold a list of sub-records: a school with several addresses, a contract with many line items, a bus route with an ordered list of stops. In CSV, the same data needs either several linked tables or awkward repeated columns. JSON also distinguishes numbers from strings, so "01234" stays a string.
For very large datasets, publishers often use JSON Lines, where each line is one complete JSON object. That keeps JSON's structure while letting users stream the file record by record, much as they would read a CSV.
| Question | CSV | JSON |
|---|---|---|
| Best data shape | One flat table | Nested or irregular records |
| Opens in a spreadsheet | Yes, directly | Not without conversion |
| Data types | None (everything is text) | Strings, numbers, booleans, null |
| Encoding | Not specified in the file | UTF-8 required for exchange (RFC 8259) |
| File size for the same table | Smaller (column names written once) | Larger (field names repeated per record) |
| Typical use | Bulk downloads, statistics, registers | APIs, web applications, complex records |
| Describing the columns | Separate metadata file (e.g. CSVW) | Separate schema (e.g. JSON Schema) |
Most CSV problems appear when the file is opened rather than when it is written. Spreadsheet software guesses types: long identifiers are turned into scientific notation, leading zeros vanish from postcodes and phone codes, and strings that look like dates are converted. Microsoft Excel also stops at 1,048,576 rows per worksheet, so a large file can be silently cut short for anyone who opens it that way.
A few habits prevent most of the damage:
2026-11-04), which is unambiguous;W3C's CSV on the Web work, published as Recommendations in December 2015, standardises that last point. A metadata file named after the data (for countries.csv, the file countries.csv-metadata.json) can declare column names, data types, units, the primary key and the licence, and can guide conversion of the CSV to JSON or RDF.
JSON's flexibility is also its weakness. Two JSON files with the same content can be structured very differently, so users need documentation or a schema before they can work with the data reliably. Non-programmers cannot easily open it, and very deep nesting makes analysis harder for everyone. Numbers can also be a trap: RFC 8259 notes that software may not handle very large or very precise numbers identically, so long identifiers are safer published as strings.
If you publish JSON, document the structure, keep it stable between releases, and announce changes in advance. A JSON Schema file lets users validate what they download.
Tim Berners-Lee's 5-star open data scheme, often used by portals to rate releases, gives one star to data on the web under an open licence in any format, two stars to structured machine-readable data (such as an Excel file), and three stars to structured data in a non-proprietary format. Both CSV and JSON reach three stars. Four and five stars require using URIs to identify things and linking to other data, which points towards RDF and formats such as JSON-LD; see the RDF entry in the manual's File Formats appendix.
Location data has its own conventions. GeoJSON, defined in RFC 7946 (2016), is a JSON format for points, lines and polygons and is widely supported by web mapping tools. A CSV with latitude and longitude columns works well for simple point data, but shapes such as boundaries need a geographic format.
Neither is better in general. CSV suits flat, rectangular tables that people will open in a spreadsheet; JSON suits nested records and data served from an API. Many publishers offer a CSV download and a JSON API for the same dataset.
CSV is described in RFC 4180 (2005), which is an Informational RFC rather than a formal standard. It documents common practice and registers the text/csv media type. W3C's CSV on the Web Recommendations (2015) add a way to describe CSV files with metadata.
UTF-8. RFC 8259 requires JSON exchanged between systems to be UTF-8, and declaring UTF-8 for CSV avoids broken accented characters when files are opened in different tools.
Yes, for flat tables the conversion is mechanical, and W3C's CSV to JSON Recommendation defines a standard way to do it. Going from nested JSON to CSV usually means flattening or splitting the data into several tables.