โฑ๏ธ Estimated read: 2 min
|
|
Syntax Quick Reference
| Element | Syntax | Example |
|---|
| Mapping | key: value | name: app |
| Sequence | - item | - apple |
| Nested map | Indentation | server:\n host: localhost |
| Flow mapping | {k: v} | point: {x: 1, y: 2} |
| Flow sequence | [a, b] | tags: [a, b] |
| Comment | # text | # http port |
| Document start | --- | --- |
| Document end | ... | ... |
Scalar Styles
| Style | Syntax | Typed |
|---|
| Plain | value | Yes (schema) |
| Single-quoted | 'value' | No (always string) |
| Double-quoted | "value" | No (escapes) |
| Literal | | | No (newlines kept) |
| Folded | > | No (newlines folded) |
Chomping Indicators
| Indicator | Trailing Newline |
|---|
| (clip) | One kept |
|- (strip) | None |
|+ (keep) | All kept |
Anchors, Aliases, Merge
| Symbol | Purpose | Example |
|---|
&name | Anchor (define) | defaults: &d |
*name | Alias (reference) | service: *d |
<< | Merge key | <<: *d |
Standard Tags
| Tag | Type |
|---|
!!str | String |
!!int | Integer |
!!float | Float |
!!bool | Boolean |
!!null | Null |
!!timestamp | Timestamp |
!!binary | Base64 bytes |
Schema Resolution
| Schema | yes | 0x1A | 2026-05-05 |
|---|
| Failsafe | string | string | string |
| JSON | string | string | string |
| Core (1.2) | string | int | string |
| Extended (1.1) | bool | int | timestamp |
Version Differences
| Feature | YAML 1.1 | YAML 1.2 |
|---|
| Booleans | yes/no/on/off | true/false only |
| Base-60 | Yes | Removed |
| Octal | 0777 | 0o777 |
| JSON subset | No | Yes |
Common Operations (Python)
| Operation | Code |
|---|
| Parse | yaml.safe_load(f) |
| Parse multi-doc | list(yaml.safe_load_all(f)) |
| Write | yaml.dump(data, f, sort_keys=False) |
| Register tag | yaml.add_constructor(tag, fn, Loader=yaml.SafeLoader) |
Security Rules
| Rule | Detail |
|---|
Never yaml.load | Use yaml.safe_load |
| Alias bombs | Bound expansion, size cap |
| Quoted hash | # in quotes is literal |
| Register on SafeLoader | Pass Loader=yaml.SafeLoader |
Common Traps
| Trap | Fix |
|---|
NO โ false (1.1) | Quote as "NO" |
1.10 โ 1.1 | Quote as "1.10" |
| Unquoted URL colon | url: "postgres://..." |
| Tab indentation | Use spaces only |
Field array index key | Use field.id |
Block Scalar Behavior
| Input | | Output | > Output |
|---|
line one\nline two | "line one\nline two\n" | "line one line two\n" |
Quick How-To Guides & Fast FixesNeed a quick fix or step-by-step solution? Browse our fast answers on HowTo.KandZ.me:
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!