Articles
Published · November 18, 2026

YAML Booleans: Why yes, no, and on Turn Into true and false

Under YAML 1.1 a bare yes, no, on, or off is a boolean, not text. See the full list, what YAML 1.2 changed, and how quotes keep a value as a string.

Also in: Español中文हिन्दी

In YAML 1.1, the words yes, no, on, and off are booleans, so answer: no gives you false, not the text "no". YAML 1.2 narrowed that to true and false, and which rule you get depends on the parser that reads your file.

Quick answer

  • Under YAML 1.1, y, n, yes, no, on, off, true, and false are all booleans, in several letter cases.
  • Under YAML 1.2's core schema, only true and false (in three cases) are.
  • To keep a word as text, put quotes around it. To write a real boolean, use true or false.

How it actually works

YAML uses implicit typing: when a value has no quotes, the parser matches it against a list of patterns and picks a type. The YAML 1.1 boolean type defines its pattern like this:

y|Y|yes|Yes|YES|n|N|no|No|NO
|true|True|TRUE|false|False|FALSE
|on|On|ON|off|Off|OFF

The page describes booleans as "formatted as English words (true/false, yes/no or on/off) for readability" that "may be abbreviated as a single character y/n or Y/N". It is a 2005 working draft, and its own example shows the effect:

canonical: y
answer: NO
logical: True
option: on

Every value there is a boolean. That's fine when you meant a boolean. When you didn't, it's a surprise:

# Read as booleans under YAML 1.1
enabled: yes
newsletter: off
answer: no

The same goes for a list of short codes. If a list holds the two-letter code NO, a YAML 1.1 reader sees false there, because NO is on the list above. That follows from the list itself. It isn't a reported incident.

The Wikipedia article on YAML shows the same split: a bare Yes is a boolean under YAML 1.1 and a string under YAML 1.2. It also names implicit type detection, such as unquoted Yes and No, as a common source of YAML errors.

One more place the word turns up is a key rather than a value. A GitHub Actions workflow file starts a trigger block with on:, and on is exactly one of the words on the 1.1 list. Keys and values are both plain scalars, so the same typing rules apply to them.

What YAML 1.2 changed

The YAML 1.2.2 specification explains the history. YAML 1.2 was published in 2009, and "its primary focus was making YAML a strict superset of JSON. It also removed many of the problematic implicit typing recommendations."

For booleans, that means:

| Schema | Resolves to boolean | |---|---| | YAML 1.1 type | y, n, yes, no, on, off, true, false (and case variants) | | YAML 1.2 core | true, True, TRUE, false, False, FALSE | | YAML 1.2 JSON | true, false |

The failsafe schema has no boolean at all: it knows only maps, sequences, and strings.

So no is a string under the 1.2 core schema and a boolean under 1.1. The catch: a file doesn't say which version it expects. The behavior comes from the parser, so check the documentation of the tool that reads your file instead of assuming.

When to use it (and when to skip it)

Rules of thumb that work under both versions:

  1. Write real booleans as `true` or `false`. Both versions agree on those.
  2. Quote any word that could be read as a boolean when you mean text. That covers yes, no, on, off, y, and n.
enabled: true        # a boolean in both versions
answer: "no"         # always the string no
country: "NO"        # always the string NO

GitHub's own documentation lists the words its parser treats as booleans, including y, yes, no, on, and off and their capitalized forms, in its guide to issue form validation errors. Quoting is the fix it points to.

There's a trade-off. Quoting every string makes a file noisy, and ordinary words don't need quotes. Reserve them for values that match the list above, and for anything a person might later change to a similar word.

If you are choosing a format and these rules feel like a lot, a format with a single spelling for booleans removes the issue. TOML, for instance, uses only true and false. And when your YAML values run to several lines, the multiline string styles are a separate topic with their own traps.

How Carets fits in

Config files are plain text, and most mistakes in them are visible if you look. Carets is a fast, native notes and code editor for iPhone, iPad, and Mac that opens .yml and .yaml files as plain text, with syntax highlighting for code and config files. A stray unquoted no is easier to spot when the value is colored differently from the quoted strings around it.

You can keep a folder of config snippets as files, group them into projects, and tag the ones where a boolean surprise bit you. Carets doesn't validate YAML or tell you which version your parser follows; you still check that in the tool's documentation. For a quick edit to a config file on your phone or Mac, though, it's a calm, native place to do it.

Get Carets on the App Store for iPhone, iPad, and Mac.

Frequently Asked Questions

Does YAML 1.2 still treat yes and no as booleans?

No. The 1.2 core schema resolves only true, True, TRUE, false, False, and FALSE to booleans, so a bare yes is a string. Whether you get that behavior depends on which version your parser implements.

How do I keep yes or no as text in YAML?

Quote it: "yes" or 'no'. A quoted value is a string under both versions.

Is on a boolean in YAML?

Under YAML 1.1, yes: on, On, and ON are booleans, along with the off forms. Under the 1.2 core schema, no.

Are y and n booleans too?

In the YAML 1.1 type definition, yes: the single letters y, Y, n, and N are listed. Quote them if you mean letters.