What is YAML?

YAML (YAML Ain't Markup Language) is a human-readable serialisation format. It represents structured data using indentation rather than brackets or tags, making it easy to read and write by hand.

Syntax Basics

# A YAML config example
server:
  host: example.com
  port: 8080
  tls: true

allowed_ips:
  - 10.0.0.1
  - 10.0.0.2
  • Key-value pairskey: value
  • Nested objects — indented with 2 spaces (never tabs)
  • Lists — items prefixed with -
  • Comments — lines starting with #
  • Strings — usually unquoted; use quotes if the value contains special characters

Where YAML Is Used

  • Docker Composedocker-compose.yml defines services
  • Kubernetes — all resource manifests are YAML
  • GitHub Actions — workflow files in .github/workflows/
  • Ansible — playbooks and inventory files
  • Helm charts — values and templates

Common Gotchas

  • No tabs — tab characters cause parse errors; use spaces only
  • Norway problem — bare NO is parsed as false in some parsers (YAML 1.1); use quotes: "NO"
  • Octal numbers0777 parses as an octal integer in YAML 1.1; quote if you mean a string
  • Multiline strings — use | to preserve newlines or > to fold them

Convert YAML to JSON or JSON to YAML: Open JSON ↔ YAML Converter →

Frequently Asked Questions

Is YAML a superset of JSON?

Yes — every valid JSON document is also valid YAML 1.2. This means you can use JSON syntax inside a YAML file (braces, brackets, quoted strings). In practice YAML files use the indentation style for readability.

What is a YAML anchor?

Anchors (&name) and aliases (*name) allow you to reuse a node in multiple places. Define once with &, reference elsewhere with *. Useful for DRY config in long Kubernetes manifests.

Related Terms

  • JSON — The stricter, more machine-friendly sibling of YAML.
  • XML — An older structured format, more verbose than YAML.