YAML surprises: the Norway problem, octal numbers and version strings

Try it in the tool

YAML to JSON

Convert and validate YAML — anchors, multi-docs and all.

YAML Validator

Find YAML errors and the gotchas that parse but bite later.

JSON to YAML

Convert JSON to readable YAML for configs and manifests.

YAML is designed to be pleasant to write, and that is the problem: when you type a plain word, the parser decides what type it is. Most of the time the guess is right. The cases where it is wrong are famous because they fail silently and look correct in the file.

Setting up the comparison

Open the YAML to JSON converter and paste this document:

country: NO
answer: yes
oct: 010
ver: 1.10
t: 1:30

The converter has a version option. Set it to 1.1 and you get "country": false, "answer": true, "oct": 8, "ver": 1.1 and "t": 90. Set it to 1.2 and you get "country": "NO", "answer": "yes", "oct": 10, "ver": 1.1 and "t": "1:30". The same text means different things depending on the version the parser implements. Only the version number kept the surprise in both: 1.10 is a number and loses its trailing zero.

The Norway problem

In YAML 1.1 an unquoted NO, No, no, N, n, off and the matching true-like words are booleans. A list of ISO country codes (SE, NO, DK) then has false in the middle, and the data looks fine until a customer in Norway cannot check out. It has been named “the Norway problem” for exactly that reason. The fix is to quote the value ("NO") or to use a YAML 1.2 parser, where only true and false are booleans.

A related effect: with 1.1 rules, the key on is a boolean too. A line like on: off becomes the pair true: false. Configuration formats that use on as a key (workflow files, for example) rely on parsers that handle it deliberately.

Octal numbers

A number with a leading zero is octal in YAML 1.1: 010 is 8. It looks like ten. This matters for file permissions (mode: 0755 is a real octal value, which is what you want) and breaks for anything that is really a decimal with padding, such as 007 or 0123. In YAML 1.2 the octal form is written 0o10, and 010 is just 10.

Sexagesimal numbers

YAML 1.1 reads 1:30 as 90, a base-60 number intended for time in minutes and seconds. The same rule turns the port mapping 22:22 into 1342 (22 × 60 + 22), which is why container documentation tells you to quote port pairs. YAML 1.2 removed this form and 1:30 stays text.

Dates and timestamps

Unquoted 2026-10-20 can be parsed as a date object by YAML 1.1 parsers. When you convert such a document to JSON, the date becomes a timestamp string (2026-10-20T00:00:00.000Z), and the converter warns you that it read a date-like value as a timestamp. If the value is a label, not a date, quote it.

Version numbers and trailing zeros

1.10 is a float, and floats do not keep trailing zeros: you get 1.1, a different version. 1.0 becomes 1. Anything with dots that identifies a release should be quoted, in every YAML version.

Rules that keep YAML honest

  1. Quote strings that look like something else: country codes, yes/no, versions, ZIP codes, phone numbers and values with a colon.
  2. Know your parser’s YAML version, and test it with the five-line document above. If you ship configuration to several tools, make it correct under both 1.1 and 1.2 by quoting.
  3. Use spaces, never tabs for indentation. Tabs are not allowed.
  4. Validate, then convert. Run the file through the YAML validator to find the exact line of a syntax error, then convert it to JSON to see what types the parser actually produced. If the JSON has false where you meant "NO", you found the bug before production.
  5. Generate, do not hand-write, when you can. The JSON to YAML converter quotes strings that would otherwise be misread ("NO", "010", "1:30", "1.10"), so a document built from JSON data is safer than one typed by hand.

Auditing a file you already have

You do not need to read every line to find the risky ones. Search the file for unquoted values that match any of these shapes: two-letter codes, yes, no, on, off, anything starting with 0, anything with a colon between digits, and anything that looks like a version or a date. Quote the ones that are text, run the file through the converter with both YAML versions, and compare the two JSON outputs. If they differ, a value in your file depends on which parser reads it, and that is a bug waiting to happen.

Why checking the JSON helps

JSON has no ambiguity: strings are quoted and the types are visible. Converting YAML to JSON is the quickest way to see what a parser really understood. Do it with a copy of the configuration you are about to deploy, in your browser, without sending the file anywhere.

Frequently asked questions

What is the Norway problem?

In YAML 1.1, the unquoted words yes, no, on, off, y, n, true and false are booleans. A list of country codes such as [SE, NO, DK] therefore contains false instead of the string NO. YAML 1.2 narrowed booleans to true and false, which fixes this, but many parsers still implement 1.1.

Which YAML version does my tool use?

Check its documentation. PyYAML follows YAML 1.1. Many newer libraries follow 1.2, and some let you choose. The converter on this site offers both so you can compare.

Should I quote every string in YAML?

Quote any value that is not obviously text: country codes, version numbers, values like yes or off, anything with a colon, a leading zero or a date-like shape. Quoting costs nothing and removes the guessing.

Why did my version 1.10 become 1.1?

Because 1.10 is a valid number, and numbers do not keep trailing zeros. The text 1.10 is a version string, so write it as "1.10".

More guides