Everything you need to know about YAML
YAML (YAML Ain't Markup Language, .yaml or .yml) is a human-friendly data serialization format that became the de facto standard for DevOps configuration. Created in 2001, YAML is whitespace-sensitive, comment-friendly, and visually clean - exactly what you want for hand-written config that gets reviewed in pull requests.
How it works under the hood
- Indentation matters. YAML uses indentation to denote structure - tabs are forbidden, spaces only. Inconsistent indentation breaks the file silently.
- Three forms. Block style (indented), flow style (JSON-like), and folded style for multi-line strings. All three can mix in one document.
- Comments allowed. `# this is a comment` survives parsing - critical advantage over JSON for human-edited config.
- Anchors and aliases. YAML has `&anchor` and `*alias` for DRY config - reuse a block in multiple places without duplication.
Where you'll actually use it
- Kubernetes manifests, Helm charts
- GitHub Actions, GitLab CI, CircleCI workflows
- Docker Compose service definitions
- Ansible playbooks, OpenAPI/Swagger specs
How it compares to alternatives
YAML vs JSON: YAML is human-friendlier with comments; JSON is machine-friendlier with strict types. YAML vs TOML: TOML is config-specific (used by Cargo, Poetry); YAML is broader. JSON vs YAML for config: prefer YAML for human-edited, JSON for machine-generated.
Things that will trip you up
- The 'Norway problem': `country: NO` parses as boolean false because YAML 1.1 has 'YES/NO/ON/OFF' as booleans. Quote string values that look like keywords
- Trailing whitespace and tabs cause silent failures - configure your editor to highlight them
- Multi-line strings have several styles (`|`, `>`, `|-`, `>+`) with different newline behaviors - know which you need