.YAML
YAML Ain’t Markup Language
Introduction
YAML is a text format for structured data that uses indentation instead of brackets, so it reads like an outline. It was first proposed in 2001, and the current specification is YAML 1.2, under which any JSON document is also valid YAML.
YAML is the common format for configuration: Docker Compose files, Kubernetes
manifests, GitHub Actions workflows and Ansible playbooks are all YAML. Files use either
.yaml or .yml.
Software
- Visual Studio Code (Windows, macOS, Linux)
- Notepad++ (Windows)
- Sublime Text (Windows, macOS, Linux)
- yq, a command-line YAML processor (Windows, macOS, Linux)
- PyYAML, the Python YAML library
Structure
A YAML file is UTF-8 text with no header. Its structure comes from three kinds of node:
- a mapping:
key: valuelines, with nested mappings indented below their key - a sequence: lines starting
-, one item each - a scalar: a plain, single-quoted or double-quoted value, or a
block of text started with
|(line breaks kept) or>(lines folded)
Indentation must use spaces, never tabs. A compact JSON-like form with
{ } and [ ] is also allowed. Comments start with
#. One file can hold several documents, each starting with a
--- line. Anchors (&name) and aliases
(*name) let a value be written once and reused.