CodeApr 8, 2026 · Updated Oct 13, 2026·4 min

JSON, YAML & XML: Developer Data Format Guide

JSON, YAML and XML compared on real data: 380 pages from our tools directory in all three formats (sizes nearly equal once gzipped; YAML parsed about 30 times slower than JSON), YAML's type-guessing traps such as NO becoming false, and safe parsing.

Try the JSON Formatter
Format, validate, and minify JSON with highlighting
→
DG
Derek Giordano
Designer & Developer
In this guide
01The Three Formats in Brief02Size and Speed, Measured03YAML's Type Guessing04Parsing Untrusted Data Safely05Choosing and Converting

The Three Formats in Brief

Here is the same record in each format, one entry from our own tool catalog:

{
  "slug": "json-formatter",
  "name": "JSON Formatter",
  "free": true
}
slug: json-formatter
name: JSON Formatter
free: true
<tool slug="json-formatter" free="true">
  <name>JSON Formatter</name>
</tool>

Size and Speed, Measured

We serialized the 380 pages of our tools directory (slug, name, description) in all three formats and parsed each one with Python 3.12.3's standard JSON and XML parsers and PyYAML 6.0.3 with the C-based libyaml loader (median of repeated runs):

FormatSizeGzippedParse time
JSON (indented)125.1 KB33.8 KB0.61 ms
JSON (minified)109.1 KB33.2 KB0.56 ms
YAML107.6 KB33.1 KB17.26 ms
XML (indented)123.7 KB33.8 KB1.66 ms

Two things stand out. Size differences mostly disappear once the file is compressed: all four versions land within about 2% of each other gzipped, so for anything served over HTTP the format barely changes the bytes on the wire. Parse time does differ: XML took about 3 times as long as JSON and YAML about 31 times, even with the C loader. That matters for large files and hot paths, not for a config file read once at startup.

YAML's Type Guessing

YAML decides types from how a value looks, and the rules changed between versions. YAML 1.1 treats yes, no, on and off as booleans, numbers with a leading zero as octal, and colon-separated numbers as base 60. YAML 1.2 (2009) dropped those rules, but many parsers still apply them, PyYAML included. The same file read by PyYAML 6.0.3 and by ruamel.yaml 0.19.1, which follows YAML 1.2:

YAML linePyYAML (YAML 1.1 rules)ruamel.yaml (YAML 1.2)
country: NOFalse'NO'
version: 1.101.11.1
time: 1:2080'1:20'
zip: 012345534912345
enabled: onTrue'on'
answer: yesTrue'yes'
port: 808080808080

Norway's country code becomes False, a time becomes 80 and a postal code becomes an octal number. Some traps survive even YAML 1.2: 1.10 is the float 1.1, so version numbers lose their trailing zero, and 012345 still loses its leading zero. The fix works everywhere: quote any value that must stay a string (country: "NO", version: "1.10").

Parsing Untrusted Data Safely

Choosing and Converting

Use JSON for APIs and machine-to-machine data: every language parses it, quickly. Use YAML for configuration people edit by hand, where comments earn their keep, and quote the values that matter. Use XML where an ecosystem already requires it: RSS and Atom feeds, sitemaps, SVG, EPUB and office documents are all XML, and our own sitemap.xml and feed.xml are no exception.

Converting JSON to YAML is safe, because YAML 1.2 is designed as a superset of JSON. YAML to JSON drops comments and expands anchors. XML to JSON is lossy, since JSON has no equivalent for attributes, namespaces or text mixed with elements, so pick a mapping convention and stick to it. The YAML ↔ JSON Converter, JSON Formatter, YAML Formatter and XML Formatter run in your browser.

DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.