What is YAML? Human-Friendly Data Serialization
Last updated: July 18, 2025 • 5 min read
📝 Definition
YAML (YAML Ain’t Markup Language) is a human-readable data serialization format designed for ease of use and clarity. Unlike markup languages, it focuses on data representation with minimal syntax, making it popular for configuration files and data exchange.
🚀 Popularity & Use Cases
- Configuration Files: Kubernetes, Ansible, and GitHub Actions use YAML.
- Data Exchange: CI/CD pipelines often export/import settings in YAML.
- Documentation: Static site generators like Jekyll and Hugo support frontmatter in YAML.
- Cloud & Infrastructure: AWS CloudFormation and Azure DevOps use YAML templates.
⚖️ YAML vs JSON
YAML and JSON both serialize data, but differ in readability and syntax:
- Readability: YAML’s indentation-based syntax is more concise and legible.
- Comments: YAML supports comments natively; JSON does not.
- Data Types: YAML supports complex types like dates, nulls, and anchors.
- Compatibility: JSON is a subset of YAML; any valid JSON is valid YAML.
📄 YAML Syntax
An example of a YAML document:
name: LangStop tools: - YAML Formatter - JSON Converter launchYear: 2025 active: true
- Use indentation (spaces) to denote nesting; no braces or brackets.
- Lists start with a dash
-
followed by a space. - Key-value pairs are written as
key: value
. - Comments begin with
#
and run until end of line.
💡 Tips & Best Practices
- Maintain consistent indentation (2 spaces is common).
- Quote strings only when necessary (e.g., containing special characters).
- Avoid tabs; YAML parsers require spaces.
- Use anchors (
&anchor
) and aliases (*anchor
) to DRY repetitive data. - Validate your YAML with online linters or CLI tools like
yamllint
.