YAML turns unquoted no, on, yes and off into booleans because the YAML 1.1 spec lists them as boolean spellings, and many parsers still follow YAML 1.1. That is the YAML Norway problem: the country code NO comes back as false. YAML 1.2 fixed it in 2009, but only parsers that implement 1.2 behave that way, so quote any value that must stay text.
What is the YAML Norway problem?
The YAML Norway problem is a YAML 1.1 parser reading Norway's country code NO as the boolean false. Bram.us shows the classic case: countries: [GB, IE, FR, DE, NO] loads in PyYAML as ['GB', 'IE', 'FR', 'DE', False]. Nothing errors. The value just changes type.
A config file looks right, the app starts, and later a lookup for country false fails somewhere far from the YAML.
Why YAML 1.1 treats no, on and yes as booleans
YAML 1.1 defines booleans as English words, so no, on, off and yes all count. The YAML 1.1 boolean type, a working draft dated 2005-01-18, says booleans are written as "true/false", "yes/no" or "on/off" for readability and may be shortened to y/n.
Its regular expression accepts 22 spellings:
| Meaning | Accepted spellings in YAML 1.1 |
|---|---|
| true | y, Y, yes, Yes, YES, true, True, TRUE, on, On, ON |
| false | n, N, no, No, NO, false, False, FALSE, off, Off, OFF |
So NO is not a special case. Any unquoted word in that table is a boolean to a 1.1 parser, which is why enabled: on becomes true and answer: yes does too.
How YAML 1.2 fixed it
YAML 1.2 only treats true and false as booleans, in three letter cases. The YAML 1.2 changes list says y, yes, on "and their negative counterparts are parsed as strings." The YAML 1.2.2 spec explains the goal: version 1.2, published in 2009, aimed to make YAML "a strict superset of JSON" and "removed many of the problematic implicit typing recommendations."
In the 1.2 core schema, the boolean spellings are true, True, TRUE, false, False and FALSE. The stricter JSON schema accepts only true and false. Under either one, NO is just a two-letter string.
Which parsers still have the Norway problem?
Parsers that implement YAML 1.1 still convert these words, and PyYAML is the best-known one. The PyYAML project page calls it "a complete YAML 1.1 parser". The ruamel.yaml docs draw the line plainly: PyYAML supports YAML 1.1, while ruamel.yaml supports YAML 1.2 and loads documents as 1.2 unless told otherwise.
In JavaScript, both main libraries default to 1.2 rules. The yaml package docs use parse('No') returning 'No' as the example, and the js-yaml changelog says load uses CORE_SCHEMA by default since 5.0.0.
The same file in four parsers
The same five lines gave three different results across the parsers I tried. I ran this on 8 November 2026:
countries: [GB, NO, SE]
enabled: on
answer: yes
y: n
version: 1.10
- PyYAML 6.0.3 (
safe_load):countriesbecame['GB', False, 'SE'], andenabledandanswerboth becameTrue. Oddly,y: nstayed as strings, even though the 1.1 type listsyandnas booleans. - js-yaml 4.1.0 and 5.5.0: everything stayed a string.
- yaml 2.9.1, default settings: same as js-yaml.
- yaml 2.9.1 with
{ version: '1.1' }, or a%YAML 1.1line at the top:NObecamefalse,onandyesbecametrue, and the keyyitself turned into"true"with the valuefalse.
That last case surprised me. Keys go through the same type rules as values, so a 1.1 parser can rename your keys.
Every parser also turned version: 1.10 into the number 1.1. That is a separate trap from booleans, but it has the same cure.
How to avoid the Norway problem
Quote any value that must stay text, and keep real booleans as true or false. A quoted scalar is always a string, in every YAML version:
countries: ["GB", "NO", "SE"]
enabled: true
version: "1.10"
- Write booleans as
true/falseonly. Every version agrees on those. - Quote codes and identifiers: country codes, version numbers, postcodes, anything that looks like a word or a number but isn't one.
- Prefer a YAML 1.2 parser for new code: ruamel.yaml in Python, or yaml or js-yaml 5 in JavaScript.
- Look for a
%YAML 1.1directive at the top of files you inherit. It switches 1.2 parsers back to the old rules.
My take: quote first, upgrade parsers second. Switching parsers fixes your code, but the same file is often read by other tools you don't control, like a CI system or a deploy script still on PyYAML. Quotes work everywhere.
The limitation is that quoting only protects the values you remember to quote. A long file edited by many people will grow a new unquoted no eventually. For a file like that, store the data as JSON, which has no implicit typing at all; JSON vs YAML for config files weighs that trade-off.
Checking what your parser actually does
The fastest check is to parse the file and look at the JSON it produces. A boolean shows up as a bare false, a string as "NO". In JavaScript that is one JSON.stringify call, as shown in converting YAML to JSON in JavaScript. For why JSON draws the line between "NO" and false so sharply, see why JSON requires double quotes. And if the file name is your only question, .yaml vs .yml covers it: the extension has no effect on any of this.
FAQ
Does YAML 1.2 still have the Norway problem?
No. The YAML 1.2 changes list says only true and false (including True and TRUE) are parsed as booleans, and y, yes, on and their negatives are parsed as strings. The problem remains in parsers that still follow YAML 1.1.
Does PyYAML have the Norway problem?
Yes. PyYAML describes itself as a complete YAML 1.1 parser. In my test, PyYAML 6.0.3 safe_load turned NO into False and both on and yes into True.
How do I stop YAML from converting NO to false?
Quote the value: "NO" or 'NO'. A quoted scalar is always a string. You can also switch to a YAML 1.2 parser such as ruamel.yaml in Python or yaml and js-yaml in JavaScript.
Are y and n booleans in YAML?
In the YAML 1.1 boolean type, yes: y, Y, n and N are listed as booleans. Parsers differ, though. PyYAML 6.0.3 left y: n alone in my test, while the JavaScript yaml package in 1.1 mode turned both the key and the value into booleans.