YAML was begun in 2001 by Clark Evans, Ori Ben-Kiki and Ingy döt Net, who wanted a format in which data is easier to read than in XML: no angle brackets and no closing tags. The name expands to “YAML Ain’t Markup Language”: the format describes data, not a document.
What YAML looks like
Structure is set by indentation: nesting is a shift to the right, not brackets. Mappings are written as “key: value”, lists as lines starting with a hyphen, strings are usually unquoted, and comments start with a hash. One file can hold several documents, separated by a line of three hyphens.
services: web: image: nginx:1.27 ports: - "8080:80" environment: DEBUG: "false" # this line is a comment Indentation and type pitfalls
The current version of the specification is 1.2.2 (October 2021). Typical mistakes come from YAML guessing the type of a value: an unquoted string may turn out to be a number or a boolean.
| Mistake | What happens |
|---|---|
| A tab in the indentation | YAML allows only spaces for indentation — the file cannot be read |
| Different indentation among siblings | items at one level must sit at the same depth, otherwise you get an error or a different document |
yes, no, on, off | read as true and false in the version 1.1 schema, plain strings in 1.2 |
| A leading zero and colons | 0777 and 19:20:30 were read as numbers in 1.1 — octal and base 60; in 1.2 octal is written 0o777, and 19:20:30 is a string |
| The Norway problem | country: no becomes false in parsers using the 1.1 schema, so the string is put in quotes |
Where it is used
- Docker Compose and Kubernetes — descriptions of containers, pods and cluster resources
- Ansible — server configuration playbooks
- CI/CD — GitHub Actions and GitLab CI pipelines, OpenAPI API descriptions
- application settings, such as Spring profiles
Sources
the term is written from these pagesVerified 9 Nov