YAML Parsing Simulator
Edit YAML and watch what the parser actually decides your values are. The Norway problem where NO becomes the boolean false, version 1.10 becoming a lower number than 1.9, leading zeros meaning octal in one spec and decimal in another, empty against null against an empty string, block scalars, and tabs. Every document is read twice, under YAML 1.1 and YAML 1.2, so you can see exactly where the two specs disagree. The parser is real and runs in your browser.
Category: DevOps
What You Will Learn
- Why `country: NO` becomes the boolean false, and which parsers do it
- Why `version: 1.10` is a lower number than `version: 1.9`
- How YAML 1.1 and YAML 1.2 disagree about the same file, and why that matters
- The difference between an empty value, `~`, `null` and an empty string
- When a leading zero means octal and when it means decimal
- What `|` and `>` do to the newlines in a CI script
- Why a repeated key silently overwrites the one above it
- How anchors, aliases and merge keys work in a CI config
- Why a tab in indentation is rejected and so hard to spot
- Why quoting is the fix for nearly all of it
Topics covered: yaml, configuration, kubernetes, ci-cd, parsing, debugging, educational, interactive
// simulator
YAML Parsing Simulator
Edit YAML and watch what the parser actually decides your values are. The Norway problem where NO becomes the boolean false, version 1.10 becoming a lower number than 1.9, leading zeros meaning octal in one spec and decimal in another, empty against null against an empty string, block scalars, and tabs. Every document is read twice, under YAML 1.1 and YAML 1.2, so you can see exactly where the two specs disagree. The parser is real and runs in your browser.
A country list, written the obvious way. Edit it and watch what changes.
countries:
-
name: "Norway"
code: "NO"
-
name: "Sweden"
code: "SE"countries:
-
name: "Norway"
code: false
-
name: "Sweden"
code: "SE"| where | you wrote | YAML 1.1 | YAML 1.2 |
|---|---|---|---|
| countries[0].code | NO | bool false | string |
About this YAML parsing simulator
What you'll learn
- That YAML resolves your untagged values into types, and which ones surprise people
- That YAML 1.1 and YAML 1.2 disagree, so the same file means different things in different tools
- Why the failures are quiet: nothing errors, a value just stops being what you meant
- The two-character fix, and when you actually need it
How it works
- The parser is real and runs in your browser. Nothing here is a canned answer.
- Every document is read twice, once under each spec, and the differences are listed.
- Edit any example. Your own YAML is resolved by the same rules.
The behaviour shown here follows the YAML 1.2.2 specification and the older YAML 1.1 boolean type, which is the one that turns Norway into false. Most tools still ship a 1.1-era resolver: that is not a bug in your file, it is a disagreement between versions of the format.
Related: the Kubernetes terminal simulator for the manifests this bites hardest, and the Git concepts simulator for the other thing everyone learns by breaking it.
Overview
YAML often decides your value is something other than what you typed. You type country: NO and get false, version: 1.10 and get 1.1, mode: 0755 and get a number, and a key on: push may come back as the boolean true. This simulator lets you edit YAML on one side and see what the parser resolved on the other, under both YAML 1.1 and YAML 1.2, because the two specifications disagree and that disagreement explains most YAML surprises. YAML 1.1 treats words like yes, no, on and off as booleans and reads numbers with leading zeros as octal, while YAML 1.2 is much stricter. The lessons cover the Norway problem, version numbers that are not strings, file modes, empty values that become null instead of an empty string, block scalars and their newlines, duplicate keys, anchors and merge keys, tabs used as indentation, and the missing space after a colon. The fix is usually the same: quote the value when it must stay a string.
Try this
- Open "The Norway problem" and compare how country: NO resolves under YAML 1.1 and YAML 1.2.
- Type version: 1.10 and then version: "1.10" to see why version numbers need quotes.
- Open "Block scalars keep your newlines" and compare the pipe and the angle bracket on a multi-line script.
Frequently asked questions
- What is the Norway problem in YAML?
- Under YAML 1.1, unquoted words such as NO, yes, on and off are read as booleans, so the country code NO for Norway becomes false. Quoting it as "NO" keeps it a string.
- What is the difference between YAML 1.1 and YAML 1.2?
- YAML 1.2 narrowed the implicit types: only true and false are booleans, and a leading zero no longer means octal. Many tools still use YAML 1.1 rules, which is why the same file can parse differently.
- When should I quote values in YAML?
- Quote anything that must stay a string but looks like another type: country codes, version numbers, values with leading zeros, yes and no, and strings that start with special characters.
Try next
// simulator
Preview Environment Simulator
See how a pull request becomes a temporary copy of your app, complete with a private URL, safe test data, review checks, and automatic cleanup.
// game
Heroku-Style Name Generator
Generate names the way Heroku, Docker, Kubernetes, and petname do, see how the word lists combine, and learn when the birthday problem makes random names collide.
// simulator
How Docker Works Under the Hood
Watch what really happens when you run docker run -p 8080:80 nginx, one layer at a time. Step down the whole stack: the CLI, the daemon, the registry pull, containerd, the OCI runtime bundle, runc, the running container, and the shared Linux kernel. Every stage shows the real low-level command you can run yourself, so it doubles as a tour of the primitives that make a container: namespaces, cgroups, and runc. A container is not a small VM, and this shows you why.