YAML CHEATSHEET & INTERACTIVE GENERATOR
An all-in-one guide and interactive builder for YAML structures. Study syntax specifications, filter options, or configure template variables to generate ready-to-use configs in real-time.
Basic Syntax & Layout5 ENTRIES
The fundamental building block of YAML, mapping an identifier (key) to a value. Must be separated by a colon and a space.
key: valueproject_name: OpenDev Hub
version: 1.2.0
status: activeOmitting the space after the colon (e.g. 'key:value'). Parsers will treat this as a single string instead of a key-value mapping.
Inline documentation or notes. The YAML parser ignores anything starting with a hash symbol.
# Comment text goes hereport: 8080 # Run service on port 8080
# Database credentials below:Attempting multi-line block comments using /* ... */ or <!-- ... -->. YAML only supports single-line comments starting with '#'.
Marks the beginning of a new YAML document within a single file or stream, allowing multi-document configurations.
------
apiVersion: v1
kind: Pod
metadata:
name: web-pod
---
apiVersion: v1
kind: Service
metadata:
name: web-servicePlacing configurations above the first '---' block, which can cause inconsistent behavior across different parsers.
Explicitly marks the end of a YAML document. It is optional but useful for streaming protocols to signal completion.
...---
message: Hello World
...
# End of document, further text starts a new sessionConfusing '...' with '---'. Use '---' to split documents and '...' to mark the complete termination of the document stream.
YAML uses whitespace indentation to define structure and parent-child relationships instead of brackets or braces.
parent:
child:
grandchild: valuedatabase:
connection:
host: localhost
port: 5432Using tab characters for indentation. YAML strictly forbids tabs. Ensure your editor converts tab keys to spaces.
Scalar Types (Data Types)5 ENTRIES
Represents whole numbers. Supports decimal, hexadecimal (base 16), octal (base 8), and binary (base 2).
decimal: 42
hexadecimal: 0x2A
octal: 0o52
binary: 0b101010max_connections: 100
color_mask: 0xFF00AA
file_permission: 0o755
bit_flags: 0b00101100Writing octal values as '0755' instead of '0o755'. In YAML 1.2, leading zeros without 'o' are parsed as decimals (755), not octals.
Represents real numbers with fractional parts, exponential notation, or special values like infinity and NaN.
float: 3.1415
exponential: 6.022e23
infinity: .inf
not_a_number: .nanpi_value: 3.14159265
delay_multiplier: 1.5e-3
max_timeout: .inf
error_rate: .nanOmitting decimals in exponential values or assuming standard JSON parsers will handle '.inf' and '.nan' values without preprocessing.
Represents logical truth values (true or false).
key: true
key: falseenable_cache: true
force_ssl: falseIn YAML 1.1, values like 'yes/no', 'on/off' are treated as booleans. If you write 'country: NO' (for Norway), it will be parsed as 'false'. Use quotes: 'country: "NO"'.
Represents missing, undefined, or empty values.
key: null
key: ~
key: middle_name: null
recovery_email: ~
optional_notes: Assuming an empty quoted string 'key: ""' is parsed as null. It is parsed as a string of length zero. Use unquoted 'null' or '~' for nulls.
Represents calendar dates and times using ISO 8601 formatting.
date: YYYY-MM-DD
timestamp: YYYY-MM-DDThh:mm:ss.sZrelease_date: 2026-07-01
created_at: 2026-07-01T13:00:00Z
local_time: 2026-07-01T07:30:00-05:00Forgetting to quote timestamps when they need to be treated as plain strings by the application (e.g. database keys or version labels).
String Styles6 ENTRIES
Strings written without single or double quotes. Convenient but subject to parsing restrictions.
key: string contentgreeting: Hello and welcome to OpenDev HubIncluding special YAML characters like ':', '#', '{', '}', '[', ']', or '&' in plain strings. If a string starts with or contains these characters, it must be quoted.
Strings enclosed in single quotes. Preserves all characters as literals and does not process escape sequences.
key: 'string content'windows_path: 'C:\Users\admin\documents'
regex_pattern: '^\d{3}-\d{2}-\d{4}$'Attempting to escape characters with backslashes (e.g., '\n' inside single quotes renders as a literal backslash followed by 'n'). To escape a single quote itself, double it: 'It''s working'.
Strings enclosed in double quotes. Processes escape sequences like '\n' (newline), '\t' (tab), and unicode characters.
key: "string content"welcome_message: "Welcome to OpenDev Hub!\nEnjoy your stay.\t🚀"Forgetting to escape backslashes when they should be literal (e.g., 'path: "C:\temp"' will escape '\t' as a tab). Use double backslashes: 'path: "C:\\temp"'.
Preserves all newlines and trailing whitespace in a multi-line string. Ideal for code blocks, logs, or certificates.
key: |
indented multiline string
second linenginx_config: |
server {
listen 80;
server_name localhost;
}Using a tab for indentation within the block or indenting the block lines less than or equal to the parent key's indentation.
Replaces single newlines in a multi-line block with spaces, folding the text into a single paragraph. Double newlines (blank lines) are preserved.
key: >
first line
second linemeta_description: >
OpenDev Hub is a neobrutalist platform
built for modern developers.
It provides fast tools, cheatsheets,
and live event trackers.Expecting newlines to be preserved. If line breaks are important (such as for scripting or certs), use the Literal scalar '|' instead.
Appended to '|' or '>' block scalars to control trailing newlines. Strip (-) removes all trailing newlines, Keep (+) retains them, and default Clip keeps exactly one.
strip: |-
content
keep: |+
contentprivate_key: |-
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC3
-----END PRIVATE KEY-----
license_footer: |+
Copyright (c) 2026 OpenDev Hub
Omitting the chomping indicator on files that are sensitive to trailing whitespace, such as private keys, breaking SSH handshakes.
Collections & Mappings5 ENTRIES
Ordered lists of values represented by bullet points using hyphens, aligned at the same indentation level.
- item1
- item2supported_frameworks:
- React
- Next.js
- Tailwind CSSForgetting the space after the hyphen (e.g. '-item'). This will parse as a single plain string '-item' rather than a list element.
Inline lists wrapped in square brackets, similar to JSON array syntax.
[item1, item2, item3]allowed_methods: [GET, POST, OPTIONS]Omitting commas between list elements or mixing block sequences with flow sequences without proper indentation.
Key-value pairs organized on multiple lines using indentation.
key:
subkey: valuedatabase_config:
host: 127.0.0.1
port: 5432
username: postgresKeys in the same mapping aligned at different indentation levels, which shifts them into nested or separate parents.
Inline key-value pairs wrapped in curly braces, matching JSON object syntax.
{key1: value1, key2: value2}headers: { Content-Type: application/json, Authorization: Bearer token123 }Omitting the space after the colon inside the curly braces. Unlike JSON, YAML flow mappings require '{key: value}' with space.
Combining mappings and sequences to build complex, multi-dimensional structures.
key:
- subkey1: value1
subkey2: value2environments:
- name: production
servers:
- ip: 192.168.1.10
role: web
- ip: 192.168.1.11
role: db
- name: staging
servers:
- ip: 192.168.2.10
role: allImproperly aligning hyphens with keys. Subkeys of a list item must be indented consistently with the start of the item.
Advanced Concepts7 ENTRIES
Marks a block of YAML data with a reference name, allowing it to be reused or duplicated later in the file.
key: &anchor_name
subkey: valuedefault_settings: &defaults
timeout: 30
retries: 3
cache_enabled: trueAttempting to reference an anchor that has not been defined yet. Anchors must be declared higher up in the file before they are used.
References a defined anchor to duplicate its content inline without re-writing it.
alias_key: *anchor_namedevelopment_env:
database: dev_db
connection_limits: *defaultsUsing the alias prefix '*' inside double quotes (e.g. '*defaults'). This will make the parser read it as a literal string '*defaults' instead of resolving the alias.
Used in combination with anchors and aliases to inject all key-values of a referenced map into the current map, allowing overrides.
<<: *anchor_name
override_key: new_valueproduction_env:
<<: *defaults
timeout: 10 # Overrides the default 30
debug: falseUsing merge keys (<<) in YAML 1.2 environments where the parser strictly adheres to 1.2 rules (as << was a YAML 1.1 type). Most modern parsers still support it for compatibility, but check parser docs.
Overrides YAML's implicit type detection by explicitly prefixing values with a type tag.
key: !!tag_name valuestring_boolean: !!str true
integer_as_string: !!str 12345
floating_value: !!float 5Typing tags incorrectly (e.g., single exclamation mark '!str' instead of double exclamation marks '!!str'). Custom tags use '!', standard built-ins use '!!'.
A collection of unique items where order is not guaranteed. Indicated by the !!set tag, where keys are separated by a question mark.
key: !!set
? item1
? item2user_permissions: !!set
? read
? write
? executeAdding duplicate items to a set. The set will collapse duplicates during parsing, resulting in only unique entries.
A sequence of key-value pairs where key order is strictly preserved, unlike standard maps which are unordered.
key: !!omap
- key1: value1
- key2: value2deployment_steps: !!omap
- checkout: git clone
- install: npm install
- build: npm run build
- deploy: pm2 restart appFormatting ordered mappings as a map rather than a sequence of single-key maps (e.g. using bullet points with hyphens). Each key-value pair in an omap must be a sequence element.
Encodes binary files (like images, zip files, or PDFs) directly in YAML as a Base64-encoded string.
key: !!binary |
base64_encoded_datapixel_gif: !!binary |
R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7Leaving out the literal block scalar '|'. Binary data must be formatted as a block scalar to support line folding and spaces in the base64 string.