Skip to content
What YAML Is
step 1/5

Reading — step 1 of 5

Read

~1 min readYAML Basics

What YAML Is

YAML ("YAML Ain't Markup Language", originally "Yet Another Markup Language") is a human-readable data format. Most associated with configuration files.

Key uses:

  • k8s manifests: pods, deployments, services.
  • CI/CD: GitHub Actions, GitLab CI, CircleCI.
  • Helm charts: Kubernetes templates.
  • Ansible playbooks: config management.
  • docker-compose: multi-container apps.
  • Application configs: many web frameworks.

Why YAML over JSON?

  • Human-friendly: less punctuation, indent-based.
  • Comments: native (JSON has none).
  • Multi-line strings: easy.
  • References: anchors + aliases (DRY).
  • Document streams: multiple docs per file.

Why JSON over YAML?

  • Stricter: no ambiguity (Norway problem, octal).
  • Faster: JSON parsers are simpler.
  • Mandatory keys quoted: less error-prone.

YAML 1.2 (2009): sub-superset of JSON. Most YAML parsers can parse JSON.

Example:

name: Alice
age: 30
emails:
  - [email protected]
  - [email protected]
address:
  street: 123 Main St
  city: Wonderland

vs JSON:

{
  "name": "Alice",
  "age": 30,
  "emails": ["[email protected]", "[email protected]"],
  "address": {
    "street": "123 Main St",
    "city": "Wonderland"
  }
}

Real implementations:

  • PyYAML (Python): mature, slow.
  • ruamel.yaml (Python): preserves comments, faster.
  • go-yaml: Go's standard.
  • js-yaml: JS.
  • snakeyaml: Java.
  • libyaml: C (reference).

We'll build a parser for a YAML subset (no anchors/tags/folded strings; cover the basics).

Reference: yaml.org spec.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…