Cheatsheet: YAML
Last updated 2026-06-21
Basic syntax
Scalars are simple values such as strings, numbers, booleans, and nulls.
Lists are sequences represented by a dash followed by a space.
Flow-style lists use JSON-like brackets.
Maps are key-value pairs separated by a colon and indented for nesting.
Flow-style maps use JSON-like braces.
Nested lists and maps are expressed with indentation, not braces.
Comments start with # and continue to the end of the line.
Strings and scalars
Plain strings usually do not need quotes, but quoting avoids ambiguity.
Use single quotes by doubling them inside single-quoted strings.
Literal block scalars with | preserve line breaks.
Folded block scalars with > fold most line breaks into spaces.
Chomping indicators control the final newline of block scalars.
Explicit tags can force values to strings or other types.
Reuse and documents
Anchors name a node and aliases reuse it elsewhere.
Merge keys copy mappings from an anchored map.
Multiple YAML documents in one stream are separated with ---.
Use explicit booleans and nulls for configuration values.
Quote values that look like booleans, numbers, dates, or special characters when they must remain strings.
See also: