YAML is a human-readable data serialization language, primarily used for writing configuration files and for data exchange between different programming languages and systems. The acronym “YAML” originally stood for “Yet Another Markup Language,” but it was later redefined as “YAML Ain’t Markup Language” to emphasize its focus on data rather than document markup.
Key Features
- Human-Readable and Minimal Syntax
- YAML is designed to be easy for humans to read and write, using indentation (similar to Python) to represent data structure, rather than brackets or braces like JSON or XML.
- It avoids the use of quotation marks and other special symbols for most values, making files cleaner and more natural to read.
YAML supports three main types of data structures:
- Mappings (Dictionaries/Maps): Key-value pairs, e.g.,
name: John
. - Sequences (Lists/Arrays): Ordered lists, e.g.,
- Scalars: Basic values like strings, numbers, booleans, and nulls.
Extensibility and Compatibility
- YAML is a strict superset of JSON, meaning any valid JSON file is also valid YAML.
- It supports custom data types and can represent complex data structures, including nested lists and dictionaries.
- YAML files typically use the
.yaml
or.yml
file extension.
Common Uses
Configuration Files
• YAML is widely used for configuration files in software projects, DevOps tools (like Ansible, Kubernetes, and CI/CD pipelines), and infrastructure-as-code definitions.
Data Serialization
• It is used to serialize and exchange data between applications, especially when readability and ease of editing by humans are important.
Automation and Orchestration
• YAML is popular in automation tools, where it defines workflows, deployment steps, and infrastructure setups in a clear, concise format.
YAML Example
A simple YAML file might look like this:
person:
name: Alice
age: 30
hobbies:
- reading
- cycling
- music
active: true