YAML Validator
Validate YAML in two passes. First, a full YAML 1.2 parser (js-yaml) checks the syntax and reports the first error with its line and column: bad indentation, tabs, unclosed quotes or brackets, and keys repeated in the same mapping. Second, a line-by-line check warns about unquoted values that YAML 1.1 parsers such as PyYAML read as something else, like no, 3.10, 01234 and 22:22. Everything runs in your browser.
How to use the YAML Validator
- Paste your YAML: a Kubernetes manifest, a Docker Compose file, a CI workflow, an Ansible playbook or any config file.
- Press Validate. A green line means every document parsed; files with several documents separated by
---are all checked. - Fix the error first if there is one (the parser stops at the first error), then review the yellow warnings.
Load example validates this file:
country: no
python_version: 3.10
zip: 01234
ports:
- 22:22
database:
host: localhost
port: 5432
It is valid YAML, and you get four warnings: line 1, no is a boolean in YAML 1.1; line 2, 3.10 is a number, so it becomes 3.1; line 3, 01234 has a leading zero; line 5, 22:22 is the base-60 number 1342 in YAML 1.1. Quoting each value removes the warning.
Errors vs warnings: what each pass checks
Errors come from the parser and mean the file is not valid YAML. Common ones:
- Duplicated mapping key. The same key twice in one mapping, such as
a: 1…a: 3at the top level, or twoport:lines underdb:. The error points at the second occurrence. Repeating a key in different list items is fine: in a Kubernetesenv:list, every item has its ownnameandvalue. - Tabs in indentation. YAML indentation must use spaces.
- Unclosed quotes or brackets, such as
a: "unterminatedora: [1, 2. - Wrong indentation, where a line is indented in a way that fits neither the parent nor a sibling.
Warnings do not make the file invalid. They flag plain (unquoted) values whose type depends on the YAML version of whoever reads the file. YAML 1.2, which this validator uses, reads them one way; YAML 1.1 parsers such as PyYAML, still common in Python tooling, read them another:
| Value | YAML 1.1 (e.g. PyYAML) | YAML 1.2 |
|---|---|---|
no, yes, on, off | boolean | string |
01234 | octal number (or a number without the zero) | number |
22:22 | base-60 number 1342 | string |
3.10 | number 3.1 | number 3.1 |
The last row is a problem in every version: an unquoted version number loses its trailing zero. Quoted values, keys, comments and the text inside | and > block strings are never flagged.
Common use cases
- Before committing a CI workflow or manifest, to catch a syntax error locally instead of in a failed pipeline run.
- Docker Compose port mappings: an unquoted
- 22:22is the classic base-60 trap, which is why the Compose documentation recommends quoting ports. - Config read by Python tools (PyYAML-based), where country codes such as
NOand values such asoffsilently become booleans. - Reviewing a merge, where two branches added the same key and the result has a duplicate that some parsers silently resolve by keeping the last value.
Limits
- The parser reports the first error only; fix it and validate again to see the next one.
- Warnings are line-based hints. They do not check flow collections (
[ ],{ }) or keys, so a key namedon:, as in GitHub Actions workflows, is not flagged. - The validator checks YAML, not a schema: it does not know which fields a Kubernetes Deployment or a GitHub workflow requires.
Frequently asked questions
My file works in my app, so why is there a warning?
off is a string for YAML 1.2 parsers and a boolean for YAML 1.1 parsers such as PyYAML. If every tool that reads the file agrees, you can ignore the warning; quoting the value makes it unambiguous.Is a duplicate key really an error?
Why is the same key in two list items not a duplicate?
- name: A and - name: B are two mappings that each have one name key.