Skip to content

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:

Language: YAML
# 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:

Flowchart of an unquoted scalar NO branching to two parsers, where YAML 1.1 leads to a coral Boolean false box and YAML 1.2 leads to a green String NO box.
A YAML 1.1 parser turns an unquoted NO into a Boolean, while a 1.2 parser keeps it a string.

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.

YAML: The Missing Battery in Python

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.

intermediate

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated Aug. 16, 2026