Getting Started
4 snippetsYAML basics and syntax
Comments
# This is a comment
# YAML is case sensitiveDocument Start
---
# Document content
key: valueMultiple Documents
---
doc: 1
---
doc: 2
---
doc: 3Document End
---
key: value
...Scalar Types
5 snippetsStrings, numbers, booleans, and null
Strings
name: John Doe
quoted: "with spaces"
single: 'also quoted'Multi-line Strings
literal: |
Line 1
Line 2
folded: >
This will
be foldedNumbers
integer: 42
float: 3.14
scientific: 1.2e+3
octal: 0o14
hex: 0xCBooleans
yes_value: true
no_value: false
also_yes: yes
also_no: noNull
empty: null
also_empty: ~
implicit_null:Collections
5 snippetsLists and dictionaries
List (Array)
fruits:
- apple
- banana
- orangeInline List
numbers: [1, 2, 3, 4, 5]Dictionary (Map)
person:
name: John
age: 30
city: NYCInline Dictionary
person: {name: John, age: 30}Nested Collections
users:
- name: Alice
roles:
- admin
- user
- name: Bob
roles:
- userTired of looking up syntax?
DocuWriter.ai generates documentation and explains code using AI.
Anchors & Aliases
3 snippetsReusing content
Anchor & Alias
defaults: &defaults
adapter: postgres
host: localhost
development:
<<: *defaults
database: dev_dbMultiple Anchors
common: &base
name: app
dev:
<<: *base
debug: true
prod:
<<: *base
debug: falseList Anchors
- &item1
name: first
- &item2
name: second
refs:
- *item1
- *item2Tags & Types
5 snippetsExplicit type declarations
String Tag
explicit_string: !!str 123
# Value is "123" not 123Integer Tag
number: !!int "42"
# Converts "42" to 42Float Tag
float_number: !!float "3.14"Boolean Tag
bool_value: !!bool "yes"Null Tag
null_value: !!null ""Advanced Features
4 snippetsComplex structures and tricks
Merge Keys
common: &common
type: base
specific:
<<: *common
name: specialSet Type
set: !!set
? item1
? item2
? item3Ordered Map
ordered: !!omap
- first: 1
- second: 2
- third: 3Binary Data
picture: !!binary |
R0lGODlhDAAMAIQAAP//9/X
17unp5WZmZgAAAOfn515eXvSpecial Characters
5 snippetsEscaping and special syntax
Escaping
special: "Quote: \" and backslash: \\"
unicode: "\u0041" # APreserve Newlines
literal: |
First line
Second line
Third lineFold Newlines
folded: >
This is a long
sentence that will
be foldedStrip Final Newlines
strip: |-
No final
newlineKeep Final Newlines
keep: |+
Multiple
final
newlinesCommon Use Cases
3 snippetsConfiguration examples
Docker Compose
version: '3'
services:
web:
image: nginx
ports:
- "80:80"Kubernetes Config
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: app
image: nginxCI/CD Pipeline
stages:
- build
- test
- deploy
build:
stage: build
script:
- make build