YAML
YAML (YAML Ain't Markup Language) is a human-readable data serialization format that is a strict superset of JSON. YAML supports comments (#), multiline strings (| and >), anchors and aliases (&, *), and unquoted strings. It is widely used for configuration files in DevOps tooling, CI/CD pipelines, and infrastructure-as-code.
YAML (YAML Ain't Markup Language) is a data serialization language designed for human readability. It uses indentation (spaces only, never tabs) to express nested structure and omits the brackets, braces, and quotation marks that make JSON verbose. YAML is a superset of JSON — any valid JSON is valid YAML — and is the standard format for Kubernetes manifests, GitHub Actions workflows, Docker Compose files, and Ansible playbooks.
Syntax Example
# Comments are supported in YAML
server:
host: localhost
port: 8080 # integers inferred from context
tls: true
tags:
- web
- primary
database:
url: postgres://localhost/mydb
pool:
min: 2
max: 10
description: |
This is a multi-line
literal block scalar.
Newlines are preserved.
summary: >
This text will be
folded into one line.
Common Pitfalls
The Norway Problem (YAML 1.1)
In YAML 1.1 (used by many parsers), no, NO, yes, YES, on, off are parsed as booleans:
countries:
- US
- NO # Parsed as false in YAML 1.1!
- SE
Fix: quote values that might be misinterpreted: "NO".
Octal Numbers
In YAML 1.1, leading zeros indicate octal: 0777 becomes 511 (decimal). Quote these values.
Indentation
YAML uses spaces only — tabs cause parse errors. Mixing tabs and spaces is a common mistake for developers familiar with Python or Makefiles.
YAML-Specific Features
# Anchors and aliases (reuse values)
defaults: &defaults
timeout: 30
retries: 3
production:
<<: *defaults # Merge anchor
host: prod.example.com
# Explicit types
port: !!int "8080"
enabled: !!bool "yes"
data: !!null ""
YAML vs JSON
YAML is for human-authored files. JSON is for machine-generated data and APIs. Never use yaml.load() in Python — use yaml.safe_load() to prevent arbitrary code execution via YAML deserialization.
Format and validate YAML with the YAML Formatter Tool.