YAML Syntax Cheat Sheet
A concise reference covering YAML indentation rules, scalars, collections, anchors, and multi-document files.
1 PageBeginnerFeb 5, 2026
Scalars & Mappings
Key-value pairs and basic scalar types.
yaml
name: Alice # string (unquoted)age: 30 # integerheight: 1.68 # floatactive: true # booleannickname: ~ # null (also 'null' or empty)description: "Uses colon: needs quotes"multiline: | Line one Line twofolded: > This becomes one long line.
Lists & Nesting
Sequences and nested structures.
yaml
fruits: - apple - banana - cherry# Inline (flow) stylecolors: [red, green, blue]person: { name: Bob, age: 25 }users: - name: Alice role: admin - name: Bob role: viewer
Anchors, Aliases & Multi-doc
Reusing values and separating multiple documents in one file.
yaml
defaults: &defaults adapter: postgres host: localhostdevelopment: <<: *defaults database: dev_dbtest: <<: *defaults database: test_db---# Second document starts herename: doc2
Rules & Common Gotchas
Indentation and quoting rules that trip people up.
- Indentation- Uses spaces only, never tabs; consistent indent defines nesting level
- Colons in strings- `key: value: extra` breaks parsing — quote the whole value: `key: "value: extra"`
- Booleans- `true/false`, `yes/no`, `on/off` all parse as booleans depending on the YAML version/parser
- Comments- Start with `#`; no block comment syntax exists
- Document separator- `---` starts a new document, `...` optionally ends one
- Quoting numbers as strings- Wrap in quotes (e.g. `version: "1.0"`) to prevent numeric coercion
Pro Tip
Watch out for the 'Norway problem': an unquoted `no` or `yes` value can be silently parsed as a boolean by YAML 1.1 parsers — always quote country codes and similar short strings.
Was this cheat sheet helpful?
Explore Topics
#YAMLSyntax#YAMLSyntaxCheatSheet#ToolsOthers#Beginner#ScalarsMappings#ListsNesting#Anchors#Aliases#DataStructures#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance