Glossary

YAML

YAML ("YAML Ain't Markup Language") is a human-readable data serialization format that uses indentation and minimal punctuation to represent nested structures, instead of JSON's braces and brackets. Since YAML 1.2 (2009), every valid JSON document is also valid YAML, but YAML adds comments, unquoted strings, multi-document files, and a much terser nested syntax — which is why it's the default format for tools like Docker Compose, Kubernetes manifests, GitHub Actions, and Ansible.

How it works

Structure is defined by indentation (spaces only — YAML forbids tabs) rather than explicit delimiters:

apiVersion: v1
kind: Pod
metadata:
  name: web
  labels:
    app: frontend
spec:
  containers:
    - name: nginx
      image: nginx:1.27
      ports:
        - containerPort: 80

Lists are marked with a leading -; maps are key: value pairs; comments start with #. YAML also supports anchors (&name) and aliases (*name) to reuse a block of config elsewhere in the same document without duplicating it, and --- separates multiple documents within a single file — both features JSON has no equivalent for.

Common pitfalls

  • The infamous "Norway problem": under YAML 1.1 parsing rules, unquoted no, yes, on, off, and country code NO (Norway) are interpreted as booleans rather than strings — YAML 1.2's core schema fixed this, but many real-world parsers (including older PyYAML defaults) still follow 1.1 rules, so quoting ambiguous-looking strings is the safe habit.
  • Mixing tabs and spaces for indentation is a parse error in YAML, unlike most languages where it's merely a style issue — an invisible tab character is a common "why won't this file load" bug.
  • Indentation errors silently change which key nests under which parent instead of raising an obvious syntax error, since almost any consistent indentation is technically "valid" YAML — just not the structure you meant.
  • YAML's flexible, comment-friendly syntax makes hand-editing easy, but that same flexibility (multiple ways to write the same value, implicit typing) makes YAML harder to diff cleanly and validate strictly than JSON.

Related terms

  • JSON — a strict subset of YAML since YAML 1.2; anything expressible in JSON can be written as YAML unchanged.
  • TOML — a config-oriented alternative that trades YAML's nesting brevity for TOML's more explicit, less ambiguous typing.
  • Docker — Docker Compose files use YAML to declare multi-container application setups.

See also

  • Tool: Kubernetes Pod YAML Generator — generate valid Kubernetes Pod YAML manifests with multi-container, volume, and resource-limit configuration.