FormatDrop
Document Format

YAML

YAML Ain't Markup Language

YAML (YAML Ain't Markup Language, originally Yet Another Markup Language) is a data serialization format designed to be readable by humans. Created in 2001, YAML uses indentation and minimal punctuation to represent data structures — no curly braces, no brackets, no quotes for simple strings. YAML is a superset of JSON (valid JSON is valid YAML), but YAML adds comments, multi-line strings, anchors and aliases (for reusing values), and multiple equivalent syntax styles. It is the standard format for Docker Compose, Kubernetes manifests, GitHub Actions, GitLab CI, Ansible playbooks, and many other DevOps tools.

What is YAML?

A YAML file uses indentation (spaces, never tabs) to show hierarchy, colons for key-value pairs, and dashes for list items. Strings don't need quotes unless they contain special characters. Comments start with `#`. YAML supports anchors (`&name`) and aliases (`*name`) to reference the same value in multiple places, reducing repetition in complex configuration files. YAML also supports multiple documents in a single file separated by `---`. The format's flexibility can be a source of errors — the 'Norway problem' (where the string 'NO' is parsed as boolean false by some YAML parsers) is a famous example of YAML's implicit type coercion causing bugs.

YAML pros and cons

Advantages

  • Comments supported — explain configuration inline with # comment syntax
  • More readable than JSON for complex nested structures (no brackets/braces)
  • Multi-line strings with literal block (|) and folded (>) styles
  • Anchors and aliases reduce repetition in large config files
  • Standard format for Docker Compose, Kubernetes, GitHub Actions, Ansible

Limitations

  • Indentation errors are silent and hard to debug — a wrong indent changes meaning
  • Implicit type coercion causes bugs (strings parsed as booleans, numbers)
  • More complex to parse than JSON — higher security risk from untrusted input
  • Multiple equivalent syntaxes (flow style vs block style) can be confusing
  • Not suitable for data interchange — use JSON or CSV for APIs and databases

When should you convert YAML files?

Use YAML for configuration files that humans frequently edit — CI/CD pipelines, Docker Compose, Kubernetes manifests, Helm charts, Ansible playbooks. Convert YAML to JSON when consuming data in JavaScript applications, REST APIs, or tools that don't support YAML. Always use `yaml.safe_load()` (Python) or equivalent safe loaders when parsing YAML from untrusted sources to prevent code execution via YAML type tags.

All FormatDrop conversions run entirely in your browser — no file upload, no server processing. Your files stay on your device.

YAML FAQ

Why does YAML parse 'NO' as false?
YAML 1.1 (used by many older parsers) defines several boolean values: `true`, `false`, `yes`, `no`, `on`, `off`, `y`, `n` (case-insensitive). So `NO`, `Yes`, `ON`, `off` are all parsed as booleans. This causes bugs when country codes (NO = Norway), git branch names, or other strings that happen to match YAML boolean literals are used as keys or values. YAML 1.2 fixed this, limiting booleans to only `true` and `false`, but many tools still use YAML 1.1 parsers.
How do I validate a YAML file?
Use `yamllint` (pip install yamllint): `yamllint file.yaml` checks for syntax errors and style issues. In VS Code, the YAML extension (by Red Hat) provides real-time validation and schema-based autocomplete. Online tools like yamllint.com validate YAML in the browser. For Kubernetes manifests specifically, `kubectl apply --dry-run=client -f manifest.yaml` validates the YAML and the Kubernetes schema.
What are YAML anchors and aliases?
Anchors define a reusable value with `&name`, and aliases reference it with `*name`. Example: `defaults: &defaults\n timeout: 30\n retries: 3\nproduction:\n <<: *defaults\n timeout: 60` — the `<<: *defaults` merges the defaults block into production, then overrides timeout. This reduces repetition in complex configs like GitHub Actions workflows that share common steps across multiple jobs.