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 wroteYAML 1.1 reads it asYAML 1.2 reads it as
nofalse"no"
ontrue"on"
0755493 (octal)755
1:2080 (base 60)"1:20"
1.101.1 (a float)1.1 (a float)
2026-11-03a 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

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 .

Try it

Related guides

Newest guides