
A Cheat Sheet of YAML Syntax for Everyday Config Files
One page of YAML syntax: scalars, quoting, collections, block strings, anchors, documents, comments and the values that change type. Copy-ready snippets.
Config files that look friendly until the indentation bites. Parsing it, linting it and avoiding its type surprises.

One page of YAML syntax: scalars, quoting, collections, block strings, anchors, documents, comments and the values that change type. Copy-ready snippets.

The same 33 scalar values loaded by a 1.1 parser and a 1.2 parser: booleans, octal, base 60 and floats. Which libraries implement which, and how to stay safe.

Six ways to write null in YAML, how they differ from the empty string, and what a key with no value, an empty list and an absent key mean to your code.

YAML allows comments with a hash, but most parsers throw them away when they load and save. What survives a round trip in PyYAML, ruamel.yaml and yq.

Edit a YAML file in code and keep its comments, anchors and quotes. PyYAML drops them, ruamel.yaml and yq keep them, and each changes some whitespace.

Define a block once with an anchor, reuse it with an alias, and merge it with the merge key. Real output shows overrides, sharing and where merging stops.

Block and flow styles for sequences and mappings, lists of mappings, empty collections and why a missing value is None, each with its parsed result.

The pipe keeps line breaks, the greater than sign folds them, and chomping indicators control the final newline. Six variants and the exact strings.

Plain, single quoted and double quoted YAML strings compared, with the characters that force quotes and a table of values that silently change type.

How YAML uses spaces to build structure, why a tab is rejected, and how one extra space turns a sibling into a child. Real parser output for each case.

Generate a Markdown table from a YAML list in Python, escaping pipes, joining lists, handling blanks and keeping the table in sync with the YAML in CI.

Read a key, value and type sheet with openpyxl, build nested YAML from dotted keys, and keep versions, dates and blanks from changing on the way.
We send one email when a new article is published. No spam.