YAML is a human-readable data serialization format used extensively in DevOps for configuration files. Docker Compose, Kubernetes manifests, GitHub Actions workflows, and CI/CD pipelines all use YAML. It uses indentation instead of brackets to represent structure.

How YAML Works

YAML looks like a cleaner version of JSON — no quotes around keys, no commas, just indentation. It supports strings, numbers, booleans, lists, and nested objects. The learning curve is gentle, but whitespace sensitivity can cause frustrating errors.

Every DevOps tool uses YAML: docker-compose.yml, Kubernetes deployment.yaml, .github/workflows/ci.yml, ansible playbooks, Helm charts. Learning YAML is a prerequisite for DevOps work.

Why Developers Use YAML

If you work with any DevOps tooling, you'll write YAML daily. It's the universal configuration language for infrastructure, CI/CD, and container orchestration. The syntax is simple, but indentation errors are the #1 cause of YAML debugging sessions.

Key Concepts

  • Indentation — YAML uses spaces (never tabs!) for structure — 2 spaces is the convention
  • Lists — Represented with dashes: - item1 on each line
  • Key-Value Pairs — Simple mappings: key: value — no quotes needed for most strings
  • Multi-line Strings — Use | for literal blocks (preserves newlines) or > for folded blocks (joins lines)

Frequently Asked Questions

Is YAML better than JSON?

YAML is more readable and supports comments. JSON is more precise and widely supported by APIs. Use YAML for config files humans edit, JSON for data exchange between services.

Why does my YAML keep breaking?

Almost always indentation. YAML requires spaces (not tabs) and consistent indentation levels. Use a YAML linter or VS Code's YAML extension to catch issues.