Software Development

JSON vs XML vs CSV: What's the Difference and Which Should You Use?

JSON vs XML vs CSV compared in plain English: what each format is, the same data in all three, when to use each and the Excel CSV problems to watch for.

Published 5 min read

On this page 9 sections
The same small brass parts packed in a tray, in nested boxes and with a paper tag on each part.

JSON, XML and CSV are three common text formats for storing data and passing it between systems. JSON is the usual choice for web apps and APIs, XML still runs sitemaps and older business integrations, and CSV is the simplest way to move a flat table in and out of spreadsheets. This guide compares them in plain English and shows when each one fits.

Short answer

  • JSON: use it for web and mobile apps and most modern APIs. It handles nested data and is easy for code to read.
  • XML: use it when a standard or system requires it, such as sitemaps and SOAP services. It is wordier but strict and self-describing.
  • CSV: use it for flat tables, spreadsheet exports and bulk imports. It cannot hold nested data and has no data types.
  • Watch out: a CSV can open wrongly in Excel because of regional settings, and Excel can drop leading zeros.
  • Rule of thumb: use whatever the other system expects. If you have a free choice, pick JSON for nested data and CSV for a simple table.

What are JSON, XML and CSV?

All three are plain text, so you can open them in Notepad and read them. They differ in how they describe the data.

JSON (JavaScript Object Notation) is defined in RFC 8259 as a lightweight, text-based, language-independent data interchange format (opens in a new window) derived from the ECMAScript standard. It holds text, numbers, true or false, null, lists and objects (groups of name and value pairs). It is strict: names need double quotes, trailing commas are forbidden and comments are not allowed (opens in a new window).

XML (Extensible Markup Language) is a W3C standard and a subset of SGML (opens in a new window). Data sits inside named tags, which can carry attributes. Its original goals included being straightforwardly usable over the Internet (opens in a new window) and supporting a wide variety of applications. Unlike JSON, XML allows comments (opens in a new window), and a schema can define typed content such as text, dates and whole numbers.

CSV (comma-separated values) is rows of text, one per line, with fields split by commas. It was never formally documented until RFC 4180 in 2005 (opens in a new window), and that RFC is informational, not an Internet standard (opens in a new window). In practice, files from different programs vary.

The same record in all three

Here is one customer with two orders. The names are made up.

{
  "customer": "Thandi Nkosi",
  "orders": [
    { "item": "Router", "qty": 2 },
    { "item": "Cable", "qty": 5 }
  ]
}
<customer name="Thandi Nkosi">
  <order item="Router" qty="2"/>
  <order item="Cable" qty="5"/>
</customer>
customer,item,qty
Thandi Nkosi,Router,2
Thandi Nkosi,Cable,5

Notice that the CSV repeats the customer name on every row, because a CSV can only hold a flat table. JSON and XML nest the orders inside the customer instead.

JSON vs XML vs CSV at a glance

JSONXMLCSV
Shape of dataNested objects and listsNested tags with attributesFlat rows and columns
Data typesText, numbers, true or false, nullText, or typed through a schemaEverything is text
CommentsNot allowedAllowedNot defined
StrictnessStrict syntaxStrict syntax, optional schemaLoose, varies by program
Common usesWeb and mobile APIs, app dataSitemaps, SOAP, older systemsExports, imports, reports
Opens neatly in ExcelNoNot directlyYes, with care

When to use each one

Use JSON when you are building or calling a modern web API, passing data between a website and a server, or storing settings with some structure. It is also the format Google recommends for structured data on web pages (opens in a new window) (as JSON-LD).

Use XML when the other side requires it. Sitemaps are one example: a sitemap is an XML file (opens in a new window) that must be UTF-8 and can list up to 50,000 URLs. SOAP web services are another, since SOAP messages are specified as XML (opens in a new window). Many older business systems still exchange XML.

Use CSV when the data is one simple table: a customer list, a price list, a month of transactions. Almost every spreadsheet, database and accounting tool can import or export it.

CSV problems to watch for in Excel

CSV looks simple, but Excel can trip you up, especially in South Africa.

Which format for data work?

For analytics, all three are common inputs. Databricks, for example, can read JSON, CSV, XML and other file types (opens in a new window). If you control the source, Databricks advises Parquet or Avro (opens in a new window), because they carry their own schema and compress better. When the source is out of your hands, the format you receive is the one you load.

How we can help

We build software and data systems that exchange data with other platforms, using REST and SOAP interfaces as well as file imports and exports. If you are unsure how two of your systems should talk to each other, or a CSV import keeps breaking, tell us what you are connecting. Read about our software development and data and database work.

Facts checked on 26 November 2026 against RFC 8259, RFC 4180, the W3C XML and SOAP specifications, sitemaps.org, MDN, Google Search Central, Microsoft Support and community answers, Unicode CLDR and Databricks documentation. Microsoft and Excel are trademarks of the Microsoft group of companies. Google is a trademark of Google LLC. Databricks is a trademark of Databricks, Inc.

Let's work together

Ready to talk? We'll reply within 2 working days. Get in touch

Let's work together

Ready to talk?

Tell us what you need. We'll reply within 2 working days.

Get in touch