YAML Validator

Check whether a YAML document parses. Errors show the line, column and a caret under the position; valid documents are checked for duplicate keys, tabs and values that other parsers read differently.

Loading tool…

About the YAML Validator

YAML is strict about indentation and surprisingly loose about everything else, which is why a file can look fine and still fail to load. This validator parses the input with js-yaml (YAML 1.2) and, on failure, shows the line and column, quotes the line with a caret under the position, and explains the parser's message: bad indentation of a mapping entry usually means that a key is not aligned with its siblings or that a value containing : needs quotes. Documents separated by --- are all checked, and the parsed result is shown as JSON so that you can see what your application will receive.

Valid YAML can still be wrong. Duplicate keys are forbidden by the specification, but PyYAML and Ruby silently keep the last value while strict parsers reject the file; every duplicate is listed with both line numbers. Tabs are not allowed for indentation. And plain scalars are typed by their look: 1.10 becomes the number 1.1, 0644 is 644 in YAML 1.2 but octal 420 in YAML 1.1, and no, yes, on and off are strings in YAML 1.2 but booleans for YAML 1.1 parsers — the reason the country code of Norway famously turned into false. The validator points these out so that you can quote them.

The check covers syntax and these pitfalls, not the meaning of the keys: whether replicas is a valid field of a Kubernetes manifest is a question for a schema. Application-specific tags such as CloudFormation's !Ref are reported as unknown tags, because a generic parser cannot construct them. Everything runs in your browser, so configuration files with internal host names or credentials do not leave your machine.

How to use it

  1. Paste your YAML or open a .yml / .yaml file.
  2. Read the result above the editors: green means the document parses.
  3. If it is invalid, go to the reported line and column; the caret marks the position and the message explains the cause.
  4. Review the warnings about duplicate keys, tabs and ambiguous values, and quote what should stay text.
  5. Check the JSON output to see the values and types that a parser produces.

Frequently asked questions

Why is the error reported on a different line than my mistake?
A parser notices a problem where the document stops making sense, which is often the line after the real cause. A wrongly indented key is reported at that key, but a missing quote or colon is reported where the next token appears. Look at the reported line and the one above it.
Is <code>no</code> a boolean or a string?
It depends on the parser. In YAML 1.2 (js-yaml, for example) only true and false are booleans, so no is a string. YAML 1.1 parsers such as PyYAML and Ruby's Psych read yes, no, on and off as booleans. Quote the value to get a string everywhere.
Are duplicate keys an error?
By the specification, yes: the keys of a mapping must be unique. In practice many parsers accept them and keep the last value without a warning, so a repeated key silently overrides an earlier one. The validator lists them as warnings and shows the last value in the output.
Can I use tabs in YAML?
Not for indentation. Tabs are only allowed inside values and as separation after the indentation. Configure your editor to insert spaces for .yml files.

Related tools