What is YAML? Complete Guide with Examples

3 min readconverter

YAML (YAML Ain't Markup Language) is a human-friendly data serialization format that uses indentation-based structure instead of brackets and braces. Designed for readability, YAML supports comments, multi-line strings, anchors/aliases for deduplication, and all JSON data types plus dates and binary data. It's the dominant format for DevOps configurations: Kubernetes manifests, Docker Compose files, GitHub Actions, Ansible playbooks, and CI/CD pipelines.

Try It Yourself

Use our free tools to experiment with yaml.

How Does YAML Work?

YAML uses indentation (spaces, never tabs) to represent structure. Key-value pairs use colons (key: value), lists use dashes (- item), and nested structures are indented by 2+ spaces. The parser reads indentation levels to build the data tree. YAML is a superset of JSON — any valid JSON is also valid YAML. Multi-line strings use | (preserve newlines) or > (fold newlines). Anchors (&name) and aliases (*name) enable reusing data blocks.

Key Features

  • Indentation-based structure without brackets — clean, readable configuration files
  • Comment support using # for inline documentation of configuration values
  • Multi-line string handling with literal (|) and folded (>) block scalars
  • Anchors and aliases for DRY (Don't Repeat Yourself) configuration sections
  • Rich type system including dates, timestamps, binary data, and null values

Common Use Cases

Kubernetes Configuration

Kubernetes manifests (Deployments, Services, ConfigMaps) are written in YAML. The format's readability and comment support make complex cluster configurations manageable.

CI/CD Pipelines

GitHub Actions, GitLab CI, CircleCI, and Azure Pipelines all use YAML for pipeline definitions. YAML's structure maps naturally to pipeline stages, jobs, and steps.

Application Configuration

Frameworks like Spring Boot, Ruby on Rails, and Django use YAML config files (application.yml, database.yml) where developers need comments and human-readable configuration.

Frequently Asked Questions

Related Guides

Related Tools