JSON vs CSV: Which Format Should You Use?

Published 24 November 2026 · 5 min read

JSON and CSV both carry data as text, and both are easy to produce, so it is tempting to treat them as interchangeable. They are not. Each fits a different shape of data and a different reader. Choosing the wrong one is the usual reason for conversion headaches later.

The short answer

Use CSV for flat tables that people will open in a spreadsheet or load into a database. Use JSON for data that has structure, such as nested objects and lists, and for anything exchanged between programs and APIs.

Side by side

CSVJSON
ShapeFlat rows and columnsNested objects and arrays
Data typesNone. Everything is text, and the reader guessesStrings, numbers, true, false, null, objects and arrays
Column namesOne optional header rowEvery value has its own key
Missing valuesAn empty cell, which is ambiguousLeave the key out, or write null
Size for the same tableSmaller, because keys are written onceLarger, because keys repeat in every record
Opens in ExcelYes, with the caveats belowNot directly; needs import or conversion
Used by APIsRarelyVery commonly
Human editingEasy in a spreadsheetEasy in a text editor if small, hard if large
SpecificationInformal; RFC 4180 describes common practiceStrict; RFC 8259

When CSV is the better choice

  • The data is naturally a table: orders, contacts, transactions, sensor readings.
  • The audience uses Excel, Google Sheets or a BI tool.
  • You are loading rows into a database table or a data warehouse.
  • File size matters and every record has the same fields.

The weakness is that CSV carries no types. A reader sees 00123 and may turn it into 123, or sees a long ID and rounds it, or sees MAR1 and shows a date. That is why spreadsheets damage IDs and codes, as explained in why Excel changes long numbers in CSV. Encoding and delimiter differences cause the other common problems, covered in garbled characters and one-column files in Excel.

When JSON is the better choice

  • Records contain lists or objects, such as an order with several items.
  • The data moves between systems, for example an API response or a webhook.
  • You need real types: a number that must stay a number, a true or false value, a null.
  • Records have different fields from one another.

The weakness is that JSON is not a table. Opening it in a spreadsheet means flattening it first, and flattening needs decisions about arrays, covered in how to flatten nested JSON into CSV.

What about YAML and XML?

YAML is mostly used for configuration files, such as Kubernetes manifests and CI pipelines, where people edit the file by hand. XML is common in older enterprise systems, feeds and some file formats. JSON is the usual choice for new APIs. You can convert JSON to YAML or XML when a system asks for one of them.

A simple way to decide

  1. Look at the shape. If every record has the same flat fields, CSV works. If records contain lists or nested objects, use JSON.
  2. Look at the reader. A person with a spreadsheet wants CSV or Excel. A program wants JSON.
  3. Look at the types. If IDs, codes or exact numbers matter, prefer JSON or an Excel file, which can hold them as text.

Converting between them

The conversion is not lossless in either direction. Going from JSON to CSV flattens structure, and going from CSV to JSON has to guess types. Use the JSON to CSV converter and the CSV to JSON converter, which keep long IDs and leading zeros as text and show a preview so you can check the result. Both run in your browser, so your data is not uploaded.