YAML Syntax

YAML syntax, data types, anchors and multi-line strings

Basic Syntax

# Key-value pairs
key: value
name: John Doe
age: 30

# Comments
# This is a comment

# Indentation (2 or 4 spaces)
Use spaces, not tabs

Collections

# List (array)
fruits:
  - apple
  - banana
  - orange

# Inline list
colors: [red, green, blue]

# Dictionary
person:
  name: John
  age: 30

Data Types

string: Hello World # string
number: 42 # integer
float: 3.14 # float
boolean: true # boolean
null_value: null # null
date: 2025-12-19 # date

Multi-line Strings

# Literal block (preserves newlines)
literal: |
  Line 1
  Line 2
  Line 3

# Folded block (joins lines)
folded: >
  This text will
  be joined

Anchors & Aliases

# Define anchor
defaults: &defaults
  timeout: 30
  retries: 3

# Reference anchor
production:
  <<: *defaults
  host: prod.example.com