What is YAML?
YAML (YAML Ain't Markup Language) is a human-readable data serialization language commonly used for configuration files and data exchange. It uses indentation to represent structure, making it more readable than JSON or XML for complex nested data.
Quick Facts
| Full Name | YAML Ain't Markup Language |
|---|---|
| Created | 2001 by Clark Evans, Ingy döt Net, Oren Ben-Kiki |
| Specification | Official Specification |
How YAML Works
YAML uses whitespace indentation to denote structure, eliminating the need for brackets or tags. It supports multiple data types including strings, numbers, booleans, null, arrays (sequences), and objects (mappings). YAML allows comments (starting with #), multi-line strings, and anchors/aliases for reusing content. It's a superset of JSON, meaning valid JSON is also valid YAML. YAML is widely used in DevOps tools like Docker Compose, Kubernetes, Ansible, and CI/CD pipelines.
Key Characteristics
- Uses indentation for structure (spaces only, no tabs)
- Supports comments with # symbol
- Multi-line string support with | and > operators
- Anchors (&) and aliases (*) for content reuse
- Superset of JSON - all JSON is valid YAML
- Multiple documents in one file separated by ---
Common Use Cases
- Configuration files (Docker Compose, Kubernetes)
- CI/CD pipeline definitions (GitHub Actions, GitLab CI)
- Infrastructure as Code (Ansible, CloudFormation)
- API specifications (OpenAPI/Swagger)
- Static site generators (Jekyll, Hugo)
Example
# Server configuration
server:
host: localhost
port: 8080
ssl: true
database:
type: postgresql
credentials:
username: admin
password: secret
features:
- authentication
- logging
- caching