glunty

YAML Syntax Cheat Sheet

A searchable reference of YAML syntax and what each piece means.

YAML syntax with a plain-English description of what each piece does
Syntax What it does
key: value Map a key to a value; a colon plus a space separates the two.
greeting: Hello world Plain unquoted string; the value runs to the end of the line.
msg: "a\nb" Double quotes process escape sequences such as newline and tab and unicode escapes.
raw: 'no escapes here' Single quotes are literal; the only escape is two single quotes standing for one.
pi: 3.14159 A floating point number, read as a float rather than a string.
count: 42 An integer value.
hex: 0x1F A hexadecimal integer; the core schema also accepts 0o octal.
sci: 6.02e23 Scientific notation for a floating point number.
active: true Boolean; the YAML 1.2 core schema accepts only true and false.
legacy: yes YAML 1.1 and many parsers read yes no on off as booleans, but YAML 1.2 core treats them as plain strings.
missing: null An explicit null value.
blank: ~ A tilde is shorthand for null; an empty value after the colon is null too.
date: 2026-07-04 An ISO 8601 date; parsers with the timestamp type read it as a date, otherwise as a string.
ts: 2026-07-04T09:30:00Z A full ISO 8601 timestamp with a time and time zone.
- item Block sequence entry; stack these lines, each starting with a dash and a space.
[a, b, c] Flow sequence: a list written inline inside square brackets.
parent: A block mapping key; the indented lines beneath it form its nested map.
{x: 1, y: 2} Flow mapping: key and value pairs written inline inside curly braces.
[[1, 2], [3, 4]] Collections nest to any depth; here a list of lists.
- {id: 1, ok: true} A sequence of maps, the usual shape for a list of records.
[] An empty list, written as empty square brackets.
{} An empty map, written as empty curly braces.
content: | Literal block scalar; every newline in the indented block below is preserved.
content: > Folded block scalar; single newlines fold to spaces while blank lines stay as breaks.
content: |- Strip chomping indicator; removes the final newline at the end of the block.
content: |+ Keep chomping indicator; keeps all trailing blank lines and the final newline.
content: >- Folded block scalar that also strips the trailing newline.
content: |2 Indentation indicator; states the block indent when the text itself starts indented.
note: "wraps over two lines" Double quoted scalars can span several lines; each line break folds to a space.
base: &defaults Anchor; label a node with an ampersand name so it can be reused later.
prod: *defaults Alias; reference an anchor with an asterisk to copy that node here.
<<: *defaults Merge key; merge the keys of the aliased map into the current map.
!!str 2026 Explicit tag; force the scalar to be read as a string.
!!int "7" Explicit tag; force the value to be read as an integer.
!!float 10 Explicit tag; force the value to be read as a float.
--- Document separator; marks the start of a document within a stream.
... Document end marker; closes a document without starting a new one.
? key Explicit key indicator for mapping keys that are not simple scalars.
!Point A local tag names an application specific type for a node.
# comment A hash begins a comment; the rest of the line is ignored by the parser.
key: value # note A comment can trail a value on the same line after whitespace.
child: Indentation sets nesting; use a consistent number of spaces at each level.
<tab> Tab characters are not allowed for indentation; use spaces only.
--- (repeated) Several documents can live in one file, each begun by its own separator line.
%YAML 1.2 A directive line; declares the YAML version before the first document.

Runs entirely in your browser. Nothing you type is sent anywhere; open DevTools and watch the Network tab to verify zero requests.

What this tool does

This is a searchable quick reference for YAML syntax, from plain scalars and block lists to anchors, tags, and multiline blocks. Each row pairs a snippet of YAML with a plain-English note on what it means. Type in the filter box to search across both columns, or tap a category button to focus on one topic. The whole table is built into the page, so it works offline and sends nothing anywhere.

How to use it

Start typing in the Filter box. Entering anchor surfaces the reuse features; entering | or > jumps to the multiline block scalars; entering bool or true shows how YAML reads booleans. The category buttons (Scalars, Collections, Multiline, Advanced, Structure) narrow the table to one topic and combine with the text filter, so you can pick Advanced and type tag to zero in on explicit typing. Clear the box to see the full sheet again.

Common use cases

  • Recalling whether a value needs quotes, and which quote style escapes what.
  • Remembering the difference between the | and > block scalars before pasting a script into a config.
  • Writing anchors and a << merge key to avoid repeating shared settings.
  • Splitting one file into several documents with --- separators.
  • Checking why a value like yes or a date is being parsed unexpectedly.

Common pitfalls

  • Tabs for indentation. YAML forbids tab characters for indentation and only accepts spaces. A stray tab is a frequent and confusing parse error, so configure your editor to insert spaces.
  • The boolean and null traps. Under many parsers bare words like yes, no, on, and off become booleans, and a country code such as NO can turn into false. Quote the value when you mean the literal text.
  • Missing the space after the colon. A mapping needs a colon followed by a space, as in key: value. Without the space the line is read as a single scalar rather than a key and value.
  • Inconsistent indentation. Sibling keys and list items must line up at the same column. Mixing indent widths inside one block silently changes the structure or raises an error.

Frequently asked questions

How does YAML represent a list?
YAML writes a list either as a block sequence, where each item sits on its own line prefixed by a dash and a space, or as a flow sequence written inline inside square brackets like [a, b, c]. Both forms produce the same data. Items can be simple scalars, or whole maps and nested lists, so a list of records is just a sequence whose entries are mappings.
What is the difference between the pipe and the greater-than sign for multiline text?
Both start a block scalar that spans several indented lines. The pipe keeps every newline exactly as written, so it suits scripts or preformatted text. The greater-than sign folds each single line break into a space and only keeps blank lines as real breaks, which suits flowing prose. With either one you can add a minus to strip the final newline or a plus to keep trailing blank lines.
How do anchors and aliases work?
An anchor labels a node by writing an ampersand followed by a name just before the value. An alias reuses that node later by writing an asterisk and the same name, so you define the value once and reference it many times. The merge key, two less-than signs followed by an alias, copies the keys of the referenced map into the current map, which is the usual way to share default settings.
Is JSON valid YAML?
Mostly yes. YAML 1.2 was designed as a superset of JSON, so a well formed JSON document is also valid YAML and parses to the same data, because YAML flow style uses the same square brackets and curly braces as JSON. The main caveats are edge cases around some number formats and duplicate keys, but for everyday data JSON can be pasted straight into a YAML file.
How does indentation work in YAML?
Indentation, using spaces only, is how YAML shows structure and nesting; tab characters are never allowed. Each deeper level is simply indented more than its parent, and the exact number of spaces is up to you as long as siblings line up consistently. Two spaces per level is the common convention. Because meaning depends on whitespace, mixing tabs and spaces or misaligning a line is the most frequent source of YAML errors.
Does this cheat sheet send anything I type to a server?
No. The whole syntax table is baked into the page and every search and filter runs locally in your browser with JavaScript, so nothing you type leaves your device. Open your browser DevTools, watch the Network tab while you use the tool, and confirm there are zero requests.

Embed this tool

Free for any use; attribution appreciated. Paste this on your site:

The embed runs the same tool that lives at this URL. No tracking; no ads inside the embed. Resize height as needed for your layout.

Cite this tool

For academic, journalistic, or technical references. Pick a format:

Citations use 2026 as the publication year. Access date is left as a fillable placeholder where the citation style expects one.

Embedded tool from glunty.com