JSON vs XML vs YAML vs CSV: When to Use Each
JSON, XML, YAML, and CSV all store structured data as text, but they are good at different things. This guide shows the same data in each format and gives a clear rule for picking one.
The same data, four ways
Here is one user record in each format.
JSON
{
"name": "Ada",
"roles": ["engineer", "author"],
"active": true
}
XML
<user>
<name>Ada</name>
<roles>
<role>engineer</role>
<role>author</role>
</roles>
<active>true</active>
</user>
YAML
name: Ada
roles:
- engineer
- author
active: true
CSV (flattened — CSV can't nest)
name,roles,active
Ada,"engineer,author",true
Strengths and trade-offs
| Format | Best at | Watch out for |
|---|---|---|
| JSON | APIs, config, nested data; universal parser support | No comments; can feel verbose |
| XML | Documents, mixed text + markup, formal schemas | Heaviest syntax; verbose |
| YAML | Config a human edits by hand; supports comments | Whitespace-sensitive — easy to mis-indent |
| CSV | Flat, tabular data; opens in any spreadsheet | No nesting, no real types — all text |
How to choose
- Building or consuming an API? Use JSON. It's the default for a reason: every language parses it and it maps cleanly to code.
- Writing config a human edits often? YAML is friendlier (comments, less punctuation) — just mind the indentation.
- Working with documents or systems that require a schema? XML still fits document-shaped, mixed content.
- Moving flat rows in and out of spreadsheets? CSV is the simplest, as long as your data has no nesting.
A good instinct: if a program produces or consumes the data, lean JSON; if a person hand-edits it, lean YAML; if it's a table, lean CSV.
Converting between them
You rarely have to rewrite data by hand. DevUtilsNow has focused converters — CSV to JSON, JSON to CSV, and YAML to JSON — all running in your browser.
Learn more
For a deeper look at JSON itself — its types and syntax rules — see The Complete Guide to JSON.
Try it
Paste JSON to format and validate it, or use one of the converters above to move between formats — everything runs locally, nothing is uploaded.