Learn YAML by Examples
1.2YAML (YAML Ain't Markup Language) is a human-readable data serialization format designed for configuration files and data exchange between programming languages. It emphasizes readability with a clean syntax that uses indentation and minimal punctuation, making it easier to read and write than JSON or XML while remaining machine-parseable.
These examples cover essential YAML features from basic syntax to advanced concepts, helping you write clear and maintainable configuration files.
Key–Value Pairs
Basic mapping structure. Learn how to define data with keys and values.
Indentation Rules
Understanding spaces and structure. YAML relies on proper indentation.
Block vs Flow Styles
Two ways to write the same data. Choose based on readability needs.
Quoted vs Unquoted Strings
When to use quotes. Learn string escaping and special cases.
Boolean Values
True and false representation. Multiple ways to express booleans.
Null Values
Representing absence of value. Three ways to express null.
Numeric Types
Numbers in different formats. Integers, floats, and special notations.
Date & Timestamp Values
Working with dates and times. ISO 8601 format support.
Sequences
Lists and arrays. Learn block and flow sequence syntax.
Mappings
Objects and dictionaries. Understanding key-value collections.
Anchors
Define reusable chunks. Mark nodes for later reference.
Aliases
Reference anchors. Reuse configuration blocks.
Multi Line Strings
Handle long text blocks. Preserve or fold line breaks.
Nested Structures
Combine lists and maps. Create complex hierarchies.
Tags
Explicit typing. Force specific data types.
Comments
Document your configuration. Add explanatory notes.
Directives
Parser instructions. Version and tag definitions.

