YAML Validator
Paste YAML to check it and see the exact line, column and document of any error, with the lines above it and a plain-English hint.
What makes YAML invalid
YAML uses indentation for structure, so one misplaced space or tab can stop a whole file from parsing. These rules all have to hold:
- Indent with spaces only. A tab at the start of a line is an error, even when your editor shows it lined up.
- Keys of one mapping, and items of one list, start at the same column. A nested block is indented further than its parent key.
- A key ends with a colon and a space:
image: nginx.image:nginxis read as one plain value, not a key. - Each key appears once per mapping.
- A value that contains
:or starts with@,`,*or&needs quotes, and#starts a comment. - Quotes,
[ ]and{ }must be closed, and an alias*nameneeds an anchor&namebefore it in the same document. ---starts a new document. Each document in the file is checked on its own.
Common YAML errors and how to fix them
Tab used for indentation. YAML indents with spaces only. Replace the tab at the start of the line with spaces, and set your editor to insert spaces in .yml files. A tab between a key and its value is fine.
Bad indentation. Items of one mapping or list must start at the same column, and a nested block must be indented further than its parent key. A [ or { that is never closed is reported here too.
Duplicate key. The same key appears twice in one mapping, which YAML does not allow. Delete one, or rename it if both values matter. Some parsers silently keep the last value instead.
Key spread over two lines. A key must fit on one line and end with a colon and a space. Usually the line above is missing the space after its colon (image:nginx), or a list item sits where a key was expected.
Mapping inside a value. A value cannot start another key: value pair on the same line, as in command: echo: hi. Quote the value, or move the nested key to its own indented line.
Missing character. Something is missing here: a closing quote, a colon after a key, or a - before a list item. The message says which.
Reserved character. A plain value cannot start with @ or `. Put the value in quotes.
Alias problem. An alias *name needs an anchor &name earlier in the same document, and cannot carry its own anchor or tag.
Syntax error. This character or token is not allowed here. Check quotes, escapes in double-quoted strings and stray punctuation.
FAQ
- Is my YAML uploaded anywhere?
- No. The parser loads once with the page, and validation runs in your browser. The YAML you paste is never sent anywhere.
- Does it check Kubernetes, Docker Compose or GitHub Actions files?
- It checks their YAML syntax, which is where most of their parse errors come from. It does not check their schemas, so a file can be valid YAML and still be rejected for an unknown or misplaced key.
- Can I validate a file with several documents?
- Yes. Separate documents with ---, as in a Kubernetes manifest that defines several resources. Every document is checked, and an error says which document it is in.
- Are duplicate keys an error?
- Yes. The YAML spec requires the keys of a mapping to be unique, so the validator flags the second one. Some parsers, PyYAML among them, accept duplicates and keep the last value, which hides the mistake.
- Which YAML version does it use?
- YAML 1.2, through the open-source yaml library for JavaScript. YAML 1.1 parsers such as PyYAML read some unquoted values differently, for example yes and no as booleans, but those values are valid in both.