YAML Validator

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

Runs in your browser Instant No sign-up
YAML
YAML input
Report

Paste, type or drop a file — output appears as you type.

Waiting for input
Processed locally · nothing is uploadedProcessed locally

What the validator checks

Paste one or more YAML documents (separated by ---). The validator parses them with the yaml library for JavaScript and:

  • shows the first syntax error with its line and column, highlighted in the editor;
  • rejects duplicate keys (unless you allow them) and aliases with no matching anchor (*name with no &name earlier in the same document);
  • warns about YAML 1.1 booleans (yes, no, on, off, y, n in any of their spellings), tabs, anchors defined twice, unknown tags, and alias trees so large that expanding them would create over a million nodes (the “billion laughs” pattern);
  • prints a report: number of documents and the type of each, YAML version, keys, depth, anchors, aliases and lines.

Values are never expanded or converted, so a billion-laughs file is checked instantly instead of freezing the tab.

Example: the Norway problem

countries:
  - code: SE
    name: Sweden
  - code: NO
    name: Norway
features:
  dark_mode: yes
  beta: off

This is valid YAML, but with version 1.2 selected the warning reads:

3 unquoted values are booleans in YAML 1.1: NO (line 4), yes (line 7), off (line 8). This check (YAML 1.2) reads them as strings, but YAML 1.1 parsers such as PyYAML and SnakeYAML read true/false. Quote them to be unambiguous.

Writing code: "NO" keeps Norway a string in every parser. For flags you mean as booleans, write true and false, which mean the same in both versions.

The classic GitHub Actions example is the top-level on: key: PyYAML reads it as the boolean True, so a Python script that loads a workflow file finds no "on" key at all.

Common errors and how to fix them

Message Cause Fix
Duplicate key "port": map keys must be unique… The same key twice in one mapping, often after a merge conflict. Delete one, or turn on Allow duplicate keys if your tool accepts it (the last value usually wins).
Tabs are not allowed as indentation An editor inserted a tab at the start of a line. Replace it with spaces; set your editor to “indent using spaces” for .yml files.
Unknown alias *default: no anchor &default is defined before it in this document. A typo in the alias name, or the anchor is in another document. Anchors do not cross ---. Fix the name, or move the anchor into the same document, above the alias.
Sequence item without - indicator A line in a list item is indented by the wrong number of spaces. Line up the item’s keys under the first key after - .
Nested mappings are not allowed in compact mappings Something like a: b: c on one line. Put the inner mapping on its own indented line, or quote the value: a: "b: c".

To turn valid YAML into JSON, use YAML to JSON; to go the other way, JSON to YAML. For JSON files, the JSON Validator runs the same kind of checks.

Options

  • YAML — 1.2 (default) or 1.1. This decides how plain values like yes, 0777 and 12:30 are read. Errors are the same in both.
  • Allow duplicate keys — off: the first duplicate is an error. On: every duplicate is listed as a warning with its line. Merge keys (<<: *defaults) can appear more than once and are never reported.

Validating in code

# PyYAML (YAML 1.1): yes/no/on/off become booleans, duplicate keys are accepted silently
import yaml
yaml.safe_load("country: NO")   # {'country': False}
// yaml (YAML 1.2), the library this page uses
import { parseAllDocuments } from 'yaml';
for (const doc of parseAllDocuments(text)) {
  for (const err of doc.errors) console.error(err.message);
}

For CI, yamllint adds style rules (line length, document start markers, truthy values) on top of syntax checks. Its truthy rule catches the same YAML 1.1 booleans.

Frequently asked questions

What is the Norway problem?

In YAML 1.1, unquoted yes, no, on, off, y and n (in several capitalisations) are booleans. A list of country codes containing NO therefore reads Norway as false in PyYAML, SnakeYAML and other YAML 1.1 parsers. YAML 1.2 only treats true and false as booleans. The validator lists these values with their line numbers, whichever version you pick, so you can quote them.

Should I pick YAML 1.2 or 1.1?

Pick the version of the parser that will read the file. The yaml package for JavaScript and ruamel.yaml for Python default to 1.2. PyYAML, SnakeYAML (used by Spring Boot) and Ruby's Psych implement 1.1. Some mix the two: go-yaml v3 follows 1.2 but still accepts yes and no when decoding into a bool field. A %YAML directive at the top of a document overrides this setting.

Are duplicate keys an error?

The YAML spec says mapping keys must be unique, so by default a repeated key is an error at the line of the second occurrence. Some tools (PyYAML, for example) accept duplicates and keep the last value. Turn on Allow duplicate keys to accept the file the same way and get a warning per duplicate instead.

Are tabs allowed in YAML?

Not for indentation — that is a syntax error. Tabs are allowed elsewhere, for example between a key's colon and its value, so the validator only warns about those and lists the lines.

Does it validate against a schema such as Kubernetes or GitHub Actions?

No. It checks YAML syntax and common YAML pitfalls, not whether the keys and values match a particular product's schema. A Deployment with a misspelled field is still valid YAML.

Is my YAML uploaded?

No. Parsing happens in your browser and nothing is uploaded, so config files with internal hostnames or credentials stay on your machine.

Last updated