What is YAML?
YAML (YAML Ain't Markup Language) is a human-readable data serialization format commonly used for configuration files, data exchange, and structured content. It uses indentation to denote structure, making it more readable than JSON for complex nested data.
YAML vs JSON
YAML is a superset of JSON — every valid JSON document is also valid YAML. YAML adds comments (#), multi-document support (---), anchors & aliases (&/*), and a more relaxed syntax. JSON is simpler and more universally supported by programming languages.
YAML 1.2 Features
YAML 1.2 (2009) is the current specification. Key features include: anchors (&) and aliases (*) for DRY content, multi-document streams separated by ---, explicit type tags (!!str, !!int, !!seq), and block/flow scalar styles.
Use Cases
Configuration files (Docker Compose, Kubernetes, CI/CD pipelines), API definitions (OpenAPI/Swagger), data serialization, log file formats, and cross-language data exchange.
Limitations
Multi-document YAML converts to a JSON array and cannot be round-tripped back to multi-document YAML. YAML's flexibility can lead to ambiguity — the same data can be represented in multiple ways. Tab indentation is not supported (YAML spec recommends spaces).