Why does YAML turn “no” into false?
You wrote a country code, a version number or a file mode, and your YAML parser handed back something else. Here is why, and how to stop it.
The Norway problem
YAML guesses the type of anything you do not quote. In the YAML 1.1 rules, the words yes, no, on, off, true and false (in lower, Title or UPPER case) all mean booleans. That was meant to be friendly for config files, but it means a list of country codes quietly loses Norway:
countries:
- GB
- IE
- NO # becomes false
The same thing bites enabled: off when you meant the text "off", answers in surveys, and the GitHub Actions on: key, which some YAML 1.1 parsers load as the boolean true rather than the word "on".
It is not only booleans
| You wrote | YAML 1.1 reads it as | YAML 1.2 reads it as |
|---|---|---|
| no | false | "no" |
| on | true | "on" |
| 0755 | 493 (octal) | 755 |
| 1:20 | 80 (base 60) | "1:20" |
| 1.10 | 1.1 (a float) | 1.1 (a float) |
| 2026-11-03 | a date | "2026-11-03" in the core schema |
Version numbers are the sneaky one: 1.10 looks like "one point ten" to you but is just a number to every YAML version, so it comes back as 1.1. Quote versions, ZIP and postal codes, phone numbers and anything with leading zeros.
Which parsers do this?
YAML 1.2 (2009) fixed most of it: in its core schema only true and false are booleans. But many popular libraries still follow 1.1 rules, PyYAML among them, and tools built on them inherit the behaviour. Libraries such as js-yaml default to 1.2. So the same file can load differently in two programs, which is the real danger.
The fix
- Quote it.
"NO"or'off'is a string in every YAML version. This is the only fix that works everywhere. - Use real booleans on purpose. Write
trueandfalsewhen you mean them, never yes/no. - Check before you ship. Paste the file into the YAML to JSON converter: it shows exactly what a parser will see and warns about each of these gotchas, with an optional "YAML 1.1 rules" switch to compare the two behaviours.
Python says No module named ‘yaml’? The package is called PyYAML: see ModuleNotFoundError: No module named.
Questions
Is NO false in YAML?
In YAML 1.1 parsers, yes: unquoted NO, No and no are all read as false. In YAML 1.2 core-schema parsers it stays the string "NO". Quoting it makes it a string in both.
Does JSON have this problem?
No. JSON has no guessing: text is always in quotes and only true and false are booleans. That is why converting YAML to JSON is a good way to see what you really wrote.
Why is the GitHub Actions on key sometimes true?
A YAML 1.1 parser reads the bare word on as a boolean, so the key becomes true. GitHub's own parser handles it, but other tools that read workflow files may not; quoting it as "on" is harmless.
Published .