YAML (YAML Ain’t Markup Language) is a human-readable data serialization format used extensively in configuration files, DevOps tooling, and data exchange. Its indentation-based structure makes it easier to read and write than JSON or XML for complex hierarchical data.
YAML Syntax Fundamentals
Key-value pairs use a colon followed by a space: name: Format Pilot. Nested objects use indentation (2 spaces is standard): the child key is indented under its parent. Lists use a dash followed by a space before each item. Comments start with # and extend to the end of the line. Multi-line strings use | for literal block style (preserving newlines) or > for folded style (joining lines).
YAML Data Types
string: hello world
integer: 42
float: 3.14
boolean_true: true
boolean_false: false
null_value: null
list:
- item one
- item two
nested_object:
key: value
another_key: another_value
Where YAML Is Used
Kubernetes uses YAML for all resource definitions — Deployments, Services, ConfigMaps, Secrets. Docker Compose uses YAML for multi-container application definitions. GitHub Actions uses YAML for CI/CD workflow definitions. Ansible uses YAML for playbooks and inventory. Helm uses YAML for chart templates. CloudFormation supports YAML (in addition to JSON) for infrastructure definitions. Most modern DevOps and configuration tools default to YAML.
YAML vs JSON
YAML is a superset of JSON — every valid JSON is valid YAML. YAML adds comments, more expressive data types, anchors and aliases for reuse, and cleaner syntax for human editing. JSON is better for machine-to-machine data exchange where strict parsing is required. For configuration files meant for humans to read and edit, YAML is almost always the better choice. Use Format Pilot’s converter to switch between YAML and JSON instantly.
Frequently Asked Questions
Why does YAML indentation matter so much?
YAML uses indentation to define the hierarchical structure of data — similar to how Python uses indentation to define code blocks. An incorrect indentation level changes the meaning of the data: a key that should be a child of an object becomes a sibling, or a list item becomes a key-value pair. Always use consistent spaces (never mix tabs and spaces) and validate YAML with a formatter before deploying.