YAML Syntax Guide: Everything You Need to Know
Published on · 199 words
Want to follow along? Open the free YAML Formatter
YAML (YAML Ain't Markup Language) is a human-friendly data serialization format widely used for configuration files.
This guide covers every aspect of YAML syntax with practical examples.
Basic Structure
YAML uses indentation to represent nesting. Spaces only, no tabs.
- key: value - a simple key-value pair
- name: John - strings do not need quotes
- age: 30 - numbers are unquoted
- active: true - booleans are true or false
Sequences and Nested Structures
Lists can be written in block style using dashes or flow style using square brackets.
- Block list: use - for each item
- Flow list: [item1, item2, item3]
- Multi-line strings: use | for literal or > for folded
Advanced Features
YAML supports anchors (&) and aliases (*) for reusing values, tags for explicit typing, and # comments.
Frequently Asked Questions
Is YAML case sensitive?▼
Yes, YAML is case sensitive. Name and name are different keys.
Can I use tabs?▼
No, YAML does not allow tabs for indentation. Use spaces only.
How do I represent null?▼
Use null, ~, or leave the value empty after the colon.
YAML vs JSON?▼
YAML is more human-readable with comments and anchors. JSON is stricter and more machine-oriented.
Try it now - free, private, and instant
Use our free YAML Formatter tool right in your browser.
Launch the YAML Formatter