Guide

YAML booleans: why yes, no, on, and off depend on the version

Prevent words such as yes, no, on, and off from changing between strings and booleans across YAML parsers and versions.

by Tools in a Tab · Published on · Reviewed on

Short answer

In YAML 1.2, booleans in the core schema are written as true and false; words such as yes, no, on, and off can remain text. YAML 1.1 recognized those same words as booleans. If you do not control the parser version and schema, quote any word that must remain a string.

The same text can produce different types

Consider this configuration:

answer: yes
switch: off
publish: true

Under YAML 1.1 resolution, yes and off can become true and false. Under the YAML 1.2 core schema, only true is unambiguously a boolean and the other two values can be strings.

The YAML 1.2.2 specification limits core-schema booleans to true and false. The historical YAML 1.1 boolean type documents y, n, yes, no, on, and off, including case variants.

Write unambiguous values

Use explicit booleans for logical data and quotes for text:

answer: 'yes'
switch: 'off'
publish: true

This matters for country codes, form responses, state names, and configuration values. Turning a string into a boolean can alter a comparison, a table column, or an API request even though the YAML does not look broken.

Inspect the actual conversion

Paste a small case into the YAML to JSON converter and inspect both value and type: strings have quotes in JSON, while booleans do not. The tool uses a documented configuration, but another system can select a different schema. The decisive test is always the parser that will run your application.

When converting back with JSON to YAML, you start from explicit JSON types. Still review strings that might look special to the final consumer.

Checklist

  1. Find out whether the system expects YAML 1.1 or 1.2 and which schema it uses.
  2. Write booleans as true or false.
  3. Quote yes, no, on, and off when they are text.
  4. Convert a sample and compare types, not just appearance.

Quotes are not noise here: they document that the value must stay text in every environment.