What is YAML?
YAML (a recursive acronym for "YAML Ain't Markup Language") is a human-friendly, data-serialization standard that can be used with all programming languages and is often used for configuration files.
If you are a DevOps engineer, YAML is your native language. You will use it every single day to:
- Define Kubernetes manifests.
- Write GitHub Actions and GitLab CI pipelines.
- Configure Ansible playbooks.
- Define infrastructure in Docker Compose.
The Origin Story
YAML was first proposed in 2001. At the time, XML was the dominant way to share data. However, XML was incredibly verbose and difficult for humans to read (filled with <tags></tags>).
YAML was designed to be the opposite: minimal, clean, and whitespace-driven. It looks more like an outline than a piece of code.
YAML vs. JSON vs. XML
To understand why YAML won the DevOps war, let's look at the same data in three different formats:
1. XML (The Legacy)
<project>
<name>GuideDevOps</name>
<tags>
<tag>Kubernetes</tag>
<tag>Docker</tag>
</tags>
</project>2. JSON (The Web Standard)
{
"project": {
"name": "GuideDevOps",
"tags": ["Kubernetes", "Docker"]
}
}3. YAML (The DevOps Standard)
project:
name: GuideDevOps
tags:
- Kubernetes
- DockerWhy YAML is the winner for Configuration:
- No Boilerplate: No closing tags, no curly braces, and no mandatory quotes.
- Comments Support: Unlike JSON, YAML allows you to write comments (
#), which is essential for explaining complex infrastructure configuration to your teammates. - Visual Hierarchy: Indentation clearly shows the structure of the data.
The "Hidden" Complexity
Because YAML is so easy to read, many engineers assume it is simple.
However, YAML has many "gotchas" regarding indentation, data types (like the "Norway Problem"), and advanced features like Anchors and Aliases.
In this tutorial series, we will move past the basics and learn how to write production-grade YAML that is clean, valid, and efficient.