YAML
YAML Ain't Markup Language
- Pronunciation
- YAM-ul
In short
YAML is a human-readable data format that uses indentation instead of brackets, widely used for configuration files in DevOps tools and CI/CD pipelines.
What is YAML?
YAML is a text format for writing structured data, such as settings, lists, and nested objects, in a way that is easy for people to read and edit. Files use the .yaml or .yml extension. The name is a recursive acronym for YAML Ain't Markup Language, chosen to stress that it is meant for data rather than documents; it originally stood for Yet Another Markup Language.
YAML uses indentation with spaces to show structure, so there are no curly braces or closing tags, and tabs are not allowed. A key: value pair defines a field, a line starting with - defines a list item, and indenting lines under a key nests them inside it. Comments start with #, and a single file can hold multiple documents separated by ---.
You will find YAML almost everywhere in DevOps: Kubernetes manifests, Docker Compose files, CI/CD pipeline definitions, and API descriptions written in the OpenAPI format. Think of it as a neatly indented outline, where the indentation alone tells you which details belong under which heading.
YAML is often compared with JSON. YAML 1.2 was designed as a superset of JSON, so almost any valid JSON document is also valid YAML, but YAML adds comments and a less cluttered syntax. The trade-off is that its flexibility can surprise you: a wrong indent silently changes the meaning, and unquoted values like no or on may be read as booleans by parsers that follow the older YAML 1.1 rules, so quote strings when in doubt.
Key takeaways
- YAML is a human-readable format for structured data and configuration.
- Indentation with spaces defines structure; tabs are not allowed.
- It supports comments with
#, unlike JSON. - YAML 1.2 is a superset of JSON, so most JSON is valid YAML.
- Quote ambiguous values such as
no,yes, oronto avoid surprise type conversions.
Example
# A simple service configuration
name: web-app
version: 2
debug: false
server:
host: 0.0.0.0
port: 8080
# A list of allowed origins
allowedOrigins:
- https://example.com
- https://admin.example.comReaders ask
What is the difference between .yaml and .yml?
There is no difference in content; both extensions mean a YAML file. The official recommendation is .yaml, but .yml is common because some older systems limited file extensions to three characters.
Is YAML better than JSON?
Neither is strictly better. YAML is easier for humans to write and supports comments, which makes it popular for configuration, while JSON is simpler, stricter, and faster to parse, which makes it the usual choice for APIs.
Why do I get indentation errors in YAML?
Because indentation defines structure, mixing tabs with spaces or misaligning a single line breaks or changes the meaning. Use spaces only, keep indentation consistent, and run a YAML linter or validator to catch mistakes early.
See also
- JSONBackend & APIs, p. 25JSON is a lightweight, text-based format for storing and exchanging structured data as key-value pairs and lists, readable by both humans and machines.
- KubernetesDevOps & Cloud, p. 32Kubernetes is an open-source system that automates deploying, scaling, and managing containerized applications across a cluster of machines.
- CI/CDDevOps & Cloud, p. 9CI/CD is a set of automated practices that build, test, and release code changes frequently, so software can be delivered to users quickly and safely.
- DockerDevOps & Cloud, p. 17Docker is an open-source platform for packaging an application and everything it needs into a container that runs the same way on any machine.
- Infrastructure as CodeDevOps & Cloud, p. 29Infrastructure as code is the practice of defining servers, networks, and other infrastructure in version-controlled files that tools apply automatically.
- SerializationBackend & APIs, p. 41Serialization is the process of converting in-memory data structures into a format such as JSON or bytes, so they can be stored or sent over a network.
Spotted a mistake or something missing on this page?Suggest an edit