FileExamples
.yaml

YAML File Format

YAML (YAML Ain't Markup Language) is a human-readable data serialization format widely used for configuration files and data exchange.

Extension .yaml
MIME text/yaml
Magic Bytes None (text-based, optional --- header)
Encoding UTF-8, UTF-16, UTF-32
Compression None (text format)
Spec YAML 1.2 (yaml.org/spec/1.2)
Max Size No theoretical limit

Sample YAML Files

View all
File NameSizeDescriptionAction
YAML Configuration2 KBDownload
Home Assistant Config5 KBDownload
ESPHome Configuration3 KBDownload
Helm Chart Values4 KBDownload
Kubernetes Manifest3 KBDownload
ArgoCD Application2 KBDownload
OpenAPI 3.0 Spec8 KBDownload
AsyncAPI Spec5 KBDownload

Overview

YAML (YAML Ain't Markup Language) is a human-friendly data serialization format that uses indentation and minimal syntax to represent structured data. Originally meaning 'Yet Another Markup Language', it was rebranded to emphasize its data-oriented nature. YAML supports scalars (strings, numbers, booleans), sequences (arrays), mappings (key-value pairs), multi-line strings, anchors/aliases (references), and multiple documents in one file. It is the dominant format for DevOps configuration (Kubernetes, Docker Compose, GitHub Actions, Ansible), API specifications (OpenAPI), and application configuration.

History

YAML was first proposed by Clark Evans in 2001 and published as YAML 1.0 in 2004. YAML 1.1 (2005) added features like merge keys. YAML 1.2 (2009) aligned the format as a superset of JSON, ensuring all valid JSON is valid YAML. The format gained massive adoption through Ruby on Rails (database.yml), Ansible playbooks, Docker Compose, Kubernetes manifests, and GitHub Actions. Today YAML is a standard in DevOps, cloud infrastructure, and CI/CD pipelines.

File Structure

YAML uses indentation (spaces, never tabs) to denote structure. Documents start with --- and end with .... Key-value pairs use 'key: value' syntax. Sequences use '- item' syntax. Multi-line strings use | (literal block) or > (folded block). Comments start with #. Anchors (&name) and aliases (*name) enable reuse. Tags (!!type) specify data types. Flow style uses {braces} and [brackets] like JSON. Complex keys use ? prefix.

Common Use Cases

  • Kubernetes manifests and Helm charts
  • Docker Compose service definitions
  • GitHub Actions / GitLab CI workflows
  • Ansible playbooks and inventory
  • Application configuration files
  • OpenAPI / Swagger API specifications
  • Cloud infrastructure (Pulumi, CloudFormation)
  • Static site generators (Jekyll, Hugo front matter)

Advantages

  • Highly human-readable — minimal syntax noise
  • Superset of JSON (YAML 1.2)
  • Comments support (JSON doesn't have comments)
  • Multi-line string support is excellent
  • Anchors and aliases reduce duplication
  • Dominant in DevOps and cloud-native tooling

Disadvantages

  • Indentation-sensitive — whitespace errors are common
  • Implicit typing can cause unexpected behavior (e.g. 'no' → false)
  • Multiple ways to represent the same data (ambiguity)
  • Security risk with arbitrary code execution in some parsers
  • Slower to parse than JSON for large files

Frequently Asked Questions

What is a YAML file?

A YAML file is a human-readable data format used primarily for configuration files. It uses indentation to represent structure and supports strings, numbers, booleans, arrays, and nested objects. It's widely used in DevOps tools like Kubernetes, Docker Compose, and CI/CD systems.

YAML vs JSON — which should I use?

Use YAML when humans need to read and edit the file (configs, CI pipelines). Use JSON for machine-to-machine data exchange (APIs, data storage). YAML supports comments and is more readable; JSON is simpler to parse and less ambiguous.

YAML vs TOML — what's the difference?

YAML uses indentation-based nesting and is more expressive but more complex. TOML uses explicit section headers ([section]) and is simpler with less ambiguity. TOML is popular for app configs (Rust Cargo.toml); YAML dominates DevOps.

Why does YAML treat 'no' as false?

YAML 1.1 interprets bare words like yes/no, on/off, true/false as booleans. Always quote strings that might be misinterpreted: 'no', 'yes', 'true', 'off'. YAML 1.2 reduced this issue by only accepting true/false.