YAML Validator and Type Inspector

See what every YAML reader will make of your file.

  • Errors by line
  • Types in 1.1 and 1.2
  • Alias bomb guard
A small clay garden path of plain stepping stones with a soft magnifying glass resting on one stone of a different colour.

The guide

A YAML file is only text until a reader picks its rules, so check it under all of them

One plain value can be a string, a boolean, an octal number or a date depending on the rule set, so a validator should show every reading and measure alias growth before building anything.

  • 0777 777 under YAML 1.2, 511 as a 1.1 octal number
  • 1:30 a string under 1.2, the base-60 integer 90 under 1.1
  • 66,429 scalars that 36 aliases in a 242-byte file would expand to
  • 94 of 94 invalid suite files refused, two by the tool's own checks
Read the full guide Fold the guide 6 min · 17 sources

Write the word no without quotes in a YAML file and the meaning depends on who reads it. To a reader that follows the YAML 1.2 rules it is the string “no”. To a reader that follows the YAML 1.1 rules it is the boolean false. The file does not say which reader it is for.

YAML is a human-readable data serialization language, commonly used for configuration files. That gap is why a file can be valid and still wrong for the program that loads it. A validator that only answers yes or no hides the gap, so this tool shows each value under every rule set side by side.

What a parser does with plain text

A parser first builds a tree. The YAML 1.2.2 text defines a stream as zero or more documents, each document as nodes, and each node as a mapping, a sequence or a scalar. Only then does a second step give each plain scalar a type, and that step belongs to a schema rather than to the grammar.

Chapter 10 of the 1.2.2 text recommends three schemas. The failsafe schema leaves a plain scalar unresolved, so everything stays a string. The JSON schema knows null, true, false and the JSON number patterns, and treats any other plain scalar as an error. The core schema adds Null, NULL and the tilde, True and TRUE, 0o octal, 0x hexadecimal, and the spellings .inf and .nan. Anything else is a string.

The YAML 1.1 type repository, a set of working drafts dated 2005, is looser. Its boolean type accepts y, n, yes, no, on and off in several letter cases. Its integer type reads a leading 0 as octal, accepts 0b binary and ignores underscores, and treats colons as base 60. Its null type accepts a tilde, the word null in three spellings and nothing at all. Its float type has a base-60 form too, its timestamp type reads dates, and two special keys exist: a double angle bracket for merging mappings and an equals sign for a default value.

Run eight plain values through both. The value no is a string under 1.2 and false under 1.1. The value 0777 is 777 under 1.2 and 511 under 1.1, because 1.1 reads the leading zero as octal. The value 0o777 is 511 under 1.2 and plain text under 1.1. The value 1:30 is a string under 1.2 and the integer 90 under 1.1, since a colon marks base 60. The value 2001-12-14 is a string under 1.2 and a date under 1.1. The values y and 1_000 follow the same split.

Two outside facts explain the surprises. Octal literals are commonly marked by a leading digit 0 or the pair 0o, which is the origin of the 0777 trap. Base 60 survives in time, angles and geographic coordinates, which is why 1.1 lets a colon build a number.

Readers also disagree with the pages. In this author’s runs on 2026-11-09, PyYAML 6.0.3 reads y and n as text, while the yaml package 2.9.0 in 1.1 mode reads them as booleans. The tool therefore labels what the stated rule set gives and adds a note where a real reader departs from it.

Anchors, aliases and merge keys

An anchor marks a node, and an alias later points back to it. The 1.2.2 text says an alias refers to the most recent preceding node with that anchor, that an alias to an anchor that never appeared is an error, and that an unused anchor is not. The same text calls anchor names a serialization detail that vanishes once the tree is composed.

That error rule needed code of its own. The yaml package composes a file with an undefined alias without complaint and fails only later, when a program reads the value. The tool therefore walks the tree, resolves every alias to its anchor, and reports a missing anchor at its line and column.

The merge key comes from 1.1. The merge page shows four maps that are equal: one written out, one merging a single mapping, one merging a list of mappings and one with an explicit key overriding the merge. In 1.1 the merged keys are inserted unless the key already exists, and earlier mappings in a list win. In 1.2 the core schema has no merge type, so the same line is an ordinary key named with two angle brackets. One line, two readings.

The alias bomb

Aliases make a file small, and that is the danger. The billion laughs attack defines ten entities that each hold ten of the one before, so a short document expands to a billion copies of the first. Wikipedia notes the idea fits any format with macro-like expansion and gives a YAML version. One YAML processor was changed to fail when its result grows too large.

The size can be computed without building anything. Count a scalar as one. Count a collection as one plus the sizes of its children. Count an alias as the size of the node its anchor names. A single pass from the bottom of the tree up gives the total, and no value is ever created.

Take a sequence of nine strings, then four more sequences that each hold nine aliases of the one before. The file is 242 bytes with 36 aliases. By the sum of 9 to the power k, it holds 9, 81, 729, 6,561 and 59,049 scalars at the five levels, which is 66,429 in all. Nine levels would hold 435,848,049. The tool reports both numbers and builds neither.

The package has its own guard. Its documentation gives a maxAliasCount of 100 by default and says a ReferenceError appears when the limit is met. That fires when a program converts the tree to values, which is too late to be useful in a page. Here the limit is the larger of 50,000 nodes and twice the nodes written, and it is checked first.

Streams, lint, and formatting that keeps comments

A stream may hold many documents. In the 1.2.2 text a bare document followed by a document end marker, then a comment and another end marker, then a literal block, makes two documents rather than three. The yaml package lists the middle one as an empty document, so the tool drops a marker-only document from its count and keeps its comment.

Errors and lint are different things. A repeated key, a tab used to indent, a bracket never closed and an alias with no anchor are errors. A key that is itself a 1.1 boolean, a trailing space, a long line, a missing final line break and an unused anchor are lint, and each can be switched off. Under 1.1 the keys true and yes also collide, which no 1.2 reader would notice.

Formatting is where a careless tool does harm. Wikipedia notes that many configuration formats let a setting be disabled by putting the comment character in front of it, so a formatter that drops comments changes the file. Loading and dumping also rewrites values: an early draft of this formatter, writing through the package’s default schema, turned 0777 into 777, which is a different number to a 1.1 reader.

The yaml package says it can write comments, and the tool uses that. It writes the text again keeping every scalar as written, reads the result back, and compares it by scalar text, by data under both rule sets, by comment and by anchor. Take a comment line, then a: 1 written with three spaces after the colon and a trailing comment, then b with two items indented four spaces. The formatted text closes the gap, moves the items to two spaces and keeps both comments, and the proof passes.

What the check cannot do

The tool reports what the named rule sets give. A program may use a reader with rules of its own, and valid YAML says nothing about whether that program accepts a key. Everything runs on this device in a worker, which MDN describes as a script running in a background thread apart from the page’s main thread, with caps on size, depth, nodes and expansion, and a file past a cap is refused with the cap named.

It was run against the yaml-test-suite release dated 2022-01-17. It refused 94 of 94 invalid files, two of them by the tool’s own checks because the package accepts them: a directive with no document and a repeated YAML directive. Of the 279 files with expected JSON, 278 match; the last differs only in how binary text is written. A passing suite is evidence about the parser, and it says nothing about your program.

Sources

Every source consulted for this guide. Links checked November 9, 2026.

  1. YAML Ain't Markup Language (YAML) revision 1.2.2 YAML Language Development Team (yaml.org)
  2. Boolean Language-Independent Type for YAML Version 1.1 yaml.org, working draft 2005-01-18
  3. Integer Language-Independent Type for YAML Version 1.1 yaml.org, working draft 2005-02-11
  4. Floating-Point Language-Independent Type for YAML Version 1.1 yaml.org, working draft 2005-01-18
  5. Null Language-Independent Type for YAML Version 1.1 yaml.org, working draft 2005-01-18
  6. Timestamp Language-Independent Type for YAML Version 1.1 yaml.org, working draft 2005-01-18
  7. Merge Key Language-Independent Type for YAML Version 1.1 yaml.org, working draft 2005-01-18
  8. Value Key Language-Independent Type for YAML Version 1.1 yaml.org, working draft 2005-01-18
  9. GitHub - yaml/yaml-test-suite at data-2022-01-17 YAML test suite authors, MIT licence
  10. GitHub - eemeli/yaml at v2.9.0 Eemeli Aro, ISC licence
  11. yaml documentation Eemeli Aro (eemeli.org)
  12. YAML - Wikipedia Wikipedia
  13. Billion laughs attack - Wikipedia Wikipedia
  14. Octal - Wikipedia Wikipedia
  15. Sexagesimal - Wikipedia Wikipedia
  16. Configuration file - Wikipedia Wikipedia
  17. Web Workers API - Web APIs | MDN MDN Web Docs (Mozilla)