YAML Cheat Sheet
Direct answer
YAML uses indentation for structure: key: value maps, dash lists, | for literal multiline, > for folded text, and &/* for anchors/aliases. Keep indentation consistent with spaces only.
Scalars
string: hello
quoted: "1.0"
literal: |
line1
line2
folded: >
one paragraphCollections
list:
- a
- b
map:
key: value
flow_list: [a, b]
flow_map: {a: 1, b: 2}Anchors
defaults: &defaults
retries: 3
service:
<<: *defaults
name: apiDocuments
%YAML 1.2
---
doc: 1
---
doc: 2
...Related
Quoting rules (quick)
- Quote values that look like booleans or numbers when you mean strings (
"NO","1.0"). - Use
|when line breaks must be kept; use>when wrapping should fold to spaces. - Indent with spaces only — tabs are invalid for indentation.
Validate quickly
Paste into the YAML.cc validator, or run yamllint / yaml.safe_load locally.