On this page 9 sections

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
| JSON | XML | CSV | |
|---|---|---|---|
| Shape of data | Nested objects and lists | Nested tags with attributes | Flat rows and columns |
| Data types | Text, numbers, true or false, null | Text, or typed through a schema | Everything is text |
| Comments | Not allowed | Allowed | Not defined |
| Strictness | Strict syntax | Strict syntax, optional schema | Loose, varies by program |
| Common uses | Web and mobile APIs, app data | Sitemaps, SOAP, older systems | Exports, imports, reports |
| Opens neatly in Excel | No | Not directly | Yes, 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.
- Wrong separator. Excel splits a CSV using the Windows list separator. In many regional settings the comma is the decimal character, so the list separator is a semicolon (opens in a new window). South Africa's official number format uses a decimal comma, although the decimal point is common in practice (opens in a new window). A file made on one PC can therefore open in a single column on another. In Excel, use Data, then From Text/CSV, and pick the delimiter (opens in a new window).
- Lost leading zeros. Phone numbers and account codes such as 007412 can lose their zeros when you double-click the file. Import the file and set the column to Text (opens in a new window) instead.
- Garbled characters. Names with accents can look wrong. Import the file and choose UTF-8 (opens in a new window).
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