Skip to content
AgileLogics

YAML Validator

Parses a YAML document and reports whether it is valid, or shows the parse error.

Working on a whole file? Open it in the YAML editor →

How it works

Paste YAML into the input panel and click Validate.

Is my YAML valid?

Paste the file and click Validate. If it parses, you'll see "Valid YAML." (with the number of documents when there's more than one). If not, you get the parser's first error with its line and column, followed by a few lines of your input and a caret pointing at the exact character. Most YAML errors are indentation or quoting mistakes that this pinpoints in seconds.

The check is a parse: the js-yaml library (version 5.4.2) loads every document in the input using the YAML 1.2 core schema from the YAML 1.2.2 specification, plus the YAML 1.1 merge key that many configuration files use. That catches syntax errors and a few structural ones (duplicate keys, undefined aliases). It does not lint style, and it doesn't know what your file is supposed to contain.

Reading an error

Here's what the validator prints for a nested block whose third line is indented by one space instead of two:

Invalid YAML: bad indentation of a mapping entry (3:2)

 1 | a:
 2 |   b: 1
 3 |  c: 2
------^

(3:2) means line 3, column 2. The caret sits under the character where the parser gave up, which is usually at or just after the real mistake. Fix that, validate again, and repeat; only the first error is reported each time.

Errors you'll actually hit

Message Typical cause Fix
bad indentation of a mapping entry A key is indented differently from its siblings Line up keys at the same depth with spaces
bad indentation of a mapping entry, on a single line An unquoted value contains colon-space, e.g. title: Note: read this Quote the value: title: "Note: read this"
tab characters must not be used in indentation A tab before a key Replace tabs with spaces; YAML forbids tabs for indentation
duplicated mapping key The same key appears twice in one mapping Delete or rename one; the YAML spec requires unique keys
unidentified alias "name" *name used before, or without, &name Define the anchor first, or fix the spelling
unknown scalar tag / unknown mapping tag !Ref, !!binary, !!set and other tags Remove the tag to check the rest of the syntax

What passes but might still be wrong

A clean result only means the text parses. These all validate, and all can bite later:

  • Unexpected types. version: 1.10 parses as the number 1.1, and zip: 01234 as 1234. Quote values that must stay text. You can see the resolved types by running the file through the YAML to JSON converter.
  • Merge keys in other tools. A merge key line (two less-than signs, a colon and an alias) is applied here, as most YAML tools do. A strict YAML 1.2 parser treats it as an ordinary key, so check how the tool that reads your file behaves if you rely on merging.
  • Wrong field names. The validator has no schema, so typos in key names pass silently.
  • Strings that look like other things. yes, no, on and off are strings under YAML 1.2. Older YAML 1.1 parsers (still used by some tools) read them as booleans, so the same file can behave differently elsewhere.

A quick checking routine

  1. Validate here to fix syntax, one error at a time.
  2. Convert to JSON to confirm values came out with the types you meant.
  3. Run the format's own tool (for example kubectl apply --dry-run=client or docker compose config) for schema-level checks.

For editing with syntax highlighting and indentation guides, open the file in the online YAML editor. If your data is JSON rather than YAML, use the JSON validator, which gives JSON-specific error messages; for XML documents there's the XML validator.

Last updated

Frequently asked questions

Does this check my Kubernetes, Compose or OpenAPI file against its schema?
No. It only checks that the YAML parses into data. A Deployment with a misspelled field such as replcas: 3 is perfectly valid YAML, so it passes. Use the tool that owns the format (kubectl, docker compose config, an OpenAPI linter) for schema rules.
Can I validate a multi-document file?
Yes. Documents separated by --- are all parsed, and the result says how many there were, for example "Valid YAML (3 documents)." An error in any document is reported with its line in the whole file.
What happens with a file that only has comments?
It's valid YAML with no data in it, and the result says so: "Valid YAML (the input contains no data — only comments or blank lines)."
Why does CloudFormation YAML with !Ref fail?
Custom tags such as !Ref, !Sub and !GetAtt aren't known to the parser, so it reports "unknown scalar tag". The template may be fine for CloudFormation; this validator just can't resolve the tags.
Is my YAML sent to a server?
No. The js-yaml parser runs in your browser and nothing is uploaded.
Is it a linter like yamllint?
No. It doesn't check line length, trailing spaces, key ordering or document-start markers. It answers one question: does this text parse as YAML?