YAML
Developer Tools
YAML Syntax Guide
YAML syntax reference: scalars, collections, anchors, multi-line strings, and comparison with JSON equivalents.
📄 Free PDF Download
Print-friendly · 1-2 pages · No sign-up required
Basic Types
| Type | YAML | JSON Equivalent |
|---|---|---|
String |
name: Alice |
"name": "Alice" |
Integer |
age: 30 |
"age": 30 |
Float |
price: 9.99 |
"price": 9.99 |
Boolean |
active: true |
"active": true |
Null |
value: null # or ~ |
"value": null |
Sequence |
- a
- b
- c |
["a", "b", "c"] |
Mapping |
key: value |
{"key": "value"} |
Collections
# Block sequence
fruits:
- apple
- banana
- cherry
# Inline sequence (flow style)
fruits: [apple, banana, cherry]
# Nested mapping
address:
street: Main St
city: Kyiv
zip: 01001
# Inline mapping (flow style)
address: {street: Main St, city: Kyiv}
Multi-line Strings
| Operator | Name | Behaviour |
|---|---|---|
| |
Literal block |
Preserves newlines |
> |
Folded block |
Newlines become spaces |
|- |
Literal, strip |
No trailing newline |
>- |
Folded, strip |
Folded, no trailing newline |
Anchors & Aliases
# Define anchor defaults: &defaults timeout: 30 retries: 3 # Reference alias (merges defaults) production: <<: *defaults host: prod.example.com development: <<: *defaults host: localhost
Common Gotchas
- › Indentation: MUST use spaces, NEVER tabs
- › yes/no/on/off are parsed as booleans (quote if literal)
- › 123 is integer; '123' is string — quote when in doubt
- › Colons in strings: must quote — title: 'Error: not found'
- › YAML 1.2 (default) fixes many YAML 1.1 quirks (octal, sexagesimal)
- › Multiple documents in one file: separate with ---
Keep This Reference Handy
Download the PDF and keep it on your desk or share with your team.
Download YAML Syntax Guide PDF