📋 JSON: JavaScript Object Notation. Lightweight, readable, widely used for APIs. Uses and [].
📄 XML: Extensible Markup Language. Powerful but verbose. Uses <> tags. Good for complex documents.
📝 YAML: YAML Ain't Markup Language. Indentation-based, most human-readable. Common for config files.
📊 Readability: YAML > JSON > XML
📦 File size: JSON < YAML < XML (XML is largest)
🔧 Parsing: JSON easiest, YAML needs indentation care, XML most complex
🌐 Browser support: JSON native, XML good, YAML needs a library
API data exchange (REST, GraphQL), frontend data, mobile data transfer. Nearly all modern APIs use JSON.
SOAP APIs, RSS/Atom feeds, SVG images, HTML's predecessor, complex documents needing namespaces and attributes.
Config files (Docker Compose, GitHub Actions, Kubernetes), CI/CD pipelines, files humans edit manually.
Same data, three representations:
JSON: {"name": "Alice", "age": 30, "skills": ["JS", "Python"]}
XML: <person><name>Alice</name><age>30</age></person>
YAML: name: Alice
age: 30
skills: [JS, Python]
Q: Will JSON replace XML?
A: It already has for APIs. But for document markup (SVG, XHTML) and enterprise systems, XML remains essential.
Q: Is YAML better than JSON?
A: More readable, but more error-prone (indentation issues). Config files → YAML, data exchange → JSON is current best practice.