YAML
YAML is a human-readable data serialization format that represents structured data through indentation instead of brackets or tags. The name is a recursive acronym for “YAML Ain’t Markup Language.” The design favors text that people can comfortably read and edit, which has made it a default choice for configuration files.
Every YAML document is built from three node kinds: mappings of key-value pairs, sequences of ordered items, and scalars such as strings and numbers. Nesting follows the indentation level, always with spaces rather than tabs, and a # starts a comment. Since version 1.2, YAML is also a strict superset of JSON, so any valid JSON document parses as YAML.
A short document, conventionally saved with a .yaml or .yml extension, can mix all three node kinds:
# Service configuration
name: web-api
replicas: 3
ports:
- 8000
- 8443
database:
host: db.internal
timeout: 2.5
Modern infrastructure tooling relies on YAML for configuration. Docker Compose files, Kubernetes manifests, and GitHub Actions workflows are all written in it. The format’s flexibility has sharp edges, though. Under the older 1.1 rules, unquoted scalars such as no and off were read as Booleans, a quirk nicknamed the Norway problem because the country code NO silently became false:
The name spells out that YAML isn’t a markup language. Unlike HTML, which annotates text within a document, YAML encodes data structures for programs to store and exchange. Python’s standard library has no YAML parser, so most projects use the third-party PyYAML library to load YAML files into dictionaries and lists.
Related Resources
Tutorial
YAML: The Missing Battery in Python
In this tutorial, you'll learn all about working with YAML in Python. By the end of it, you'll know about the available libraries, their strengths and weaknesses, and the advanced and potentially dangerous features of YAML. You'll also serialize Python objects and create a YAML syntax highlighter.
For additional information on related topics, take a look at the following resources:
- YAML: Python's Missing Battery (Course)
- Serialize Your Data With Python (Tutorial)
- Working With JSON Data in Python (Tutorial)
- Working With JSON in Python (Course)
- Build Robust Continuous Integration With Docker and Friends (Tutorial)
- Serialize Your Data With Python (Quiz)
- Working With JSON Data in Python (Quiz)
By Martin Breuss • Updated Aug. 16, 2026