Developer · Validator

YAML validator.

Paste YAML to check the syntax, find the exact line and column of an error, re-format it with consistent indentation, or convert it to JSON. Runs in your browser; nothing is sent anywhere.

Advertisement

Input

One document, or several separated by a line containing only ---.

Result

Paste YAML and press Validate.

How the YAML check works

The text is parsed by js-yaml 4.1.1, a widely used open-source YAML parser, with its default schema (the YAML 1.2 core types plus timestamps, merge keys and a few others). If parsing fails you get the parser's reason and the line and column where it stopped, both counted from 1, plus a snippet of the surrounding text.

Tabs: the YAML 1.2.2 specification (section 6.1) says indentation is made of spaces and tab characters must not be used for it. Any line whose leading whitespace contains a tab is listed as a warning. Tabs inside a value or after the content are fine.

Several documents: a YAML stream can hold more than one document, each starting with --- (section 9.2). All of them are parsed. As JSON, several documents become an array with one element per document. If a later document fails, the message names which document contains the error.

Duplicate keys: mapping keys must be unique (section 3.2.1.1), so a: 1 followed by a: 2 in the same mapping is reported as an error.

Re-formatting: the parsed data is written back out with two-space indentation and no line wrapping. This normalises quoting and layout, but comments are dropped because they are not part of the data, and anchors that point to the same object may be written as anchors and aliases. Keep your original if comments matter.

Sources: YAML Ain't Markup Language version 1.2.2 (yaml.org); js-yaml (github.com/nodeca/js-yaml), MIT licence, vendored at version 4.1.1.

Frequently asked questions

Why does YAML reject tabs for indentation?

The specification reserves indentation for spaces, because the meaning of a tab depends on the viewer's tab width. Replace leading tabs with spaces.

Is "yes" or "no" a boolean?

Not under the YAML 1.2 core schema used here: only true and false are booleans, so yes is a string. Some older YAML 1.1 tools treat yes/no/on/off as booleans, so quote them if a consumer might.

Why did my comments disappear after formatting?

Formatting re-serialises the parsed data, and comments are not data. Use the formatted output as a clean copy, not as a replacement for a commented file.

Why is a key like y written as 'y'?

The serialiser quotes plain words that some YAML 1.1 parsers read as booleans, so the output stays safe for both.

Syntax check only

This tool checks that text parses as YAML. It cannot tell you whether the content is right for Kubernetes, Docker Compose, GitHub Actions or any other tool that reads it, and other parsers may differ on edge cases. Nothing you type is stored or sent anywhere.

Advertisement
Advertisement
Listening…