This is an old revision of the document!
Table of Contents
YAML
YAML (YAML Ain’t Markup Language) is a human-readable data serialization language designed for simplicity and clarity. It is often used for configuration files, data exchange between programming languages, and declarative system descriptions (e.g., Docker Compose, GitHub Actions, Kubernetes).
History
YAML was first proposed in 2001 by Clark Evans, together with Ingy döt Net and Oren Ben-Kiki. The goal was to create a format that combined the readability of plain text with the structure of JSON or XML, making it easy for humans to write and understand while remaining machine-parsable. The acronym originally meant *“Yet Another Markup Language”*, but was later reinterpreted humorously as *“YAML Ain’t Markup Language”*, to emphasize that YAML focuses on data, not documents or markup.
Basic Idea
YAML is based on indentation and key-value pairs, allowing hierarchical (tree-like) data structures without the need for braces or brackets. It is often described as a human-friendly alternative to JSON and XML.
Comparison with JSON
| Concept | JSON | YAML | 
|---|---|---|
| Syntax | Uses braces `{}` and brackets `[]` | Uses indentation (spaces only) | 
| Comments | Not allowed | Allowed with `#` | 
| Readability | Machine-friendly | Human-friendly | 
| Common use | APIs, web data exchange | Configuration, DevOps, CI/CD | 
Example comparison:
{
  "student": {
    "name": "Anna",
    "age": 21,
    "courses": ["Programming", "Databases"]
  }
}
student: name: Anna age: 21 courses: - Programming - Databases
Syntax Rules
- Indentation defines structure (use spaces, not tabs)
 - Key-value pairs: `key: value`
 - Lists: prefix `-`
 - Nested structures: indent by two spaces
 - Comments: start with `#`
 
Example:
server: host: localhost port: 8080 enabled: true paths: - /login - /logout
Data Types
- Strings, numbers, booleans, lists, and mappings (dictionaries)
 - Multi-line strings are supported using `|` (literal) or `>` (folded):
 
description: | This text spans multiple lines.
Validation and Schema
Just like JSON Schema, YAML files can be validated using schema definitions. Common tools include Yamale, Kubeval, or the built-in schema support of IDEs such as Visual Studio Code.
Typical Use Cases
- Docker Compose (`docker-compose.yml`)
 - GitHub Actions (`.github/workflows/*.yml`)
 - Kubernetes manifests (`deployment.yaml`)
 - Python and Node.js configuration files
 
Example:
version: "3.8" services: web: image: nginx:latest ports: - "8080:80"
Educational Demo Idea
Show the same configuration both in JSON and YAML, and ask:
- Which one is easier to read?
 - What are the risks of using indentation as syntax?
 - How does the structure represent a syntax tree?
 
Summary
- YAML is a readable, indentation-based language for structured data.
 - It was created to bridge the gap between human readability and machine processing.
 - It plays a central role in modern DevOps, configuration management, and data description languages.
 
