Quiz Entry - updated: 2026.10.30
What scalar values, null values and comments can you write in YAML?
Comments start with #. Scalars are strings (plain, 'single' or "double" quoted), numbers (42, 3.14, -7) and booleans (true, false). Null is written null or ~.
# a comment runs to the end of the line
'A single-quoted string'
"A double-quoted string"
42
3.14
-7
true
false
null
~
A scalar is a single value, as opposed to a collection. YAML infers the type from how the value looks, which is convenient but has traps:
version: 1.10becomes the number 1.1. Quote it ("1.10") if it is really a string.- In older YAML (1.1, which Ansible's parser still partly follows) words like
yes,no,on,offare booleans too. That is whybecome: yesworks, but also why a country codeNOcan turn intofalse. Prefertrue/falseand quote ambiguous strings. - Double quotes allow escape sequences such as
\n; single quotes take the text literally. - A value that starts with
{{ }}(a Jinja2 variable) must be quoted, or YAML reads it as an object.
Go deeper:
YAML Syntax (official docs) — booleans, quoting and the
{{ }}gotcha.YAML 1.2.2 specification — the authoritative definition of scalars and null.