What this YAML validator checks
This YAML validator parses your document with a standards-based YAML parser and tells you whether it is syntactically valid. If it is not, you get the first problem with its line and column. If it is, the output panel shows the parsed result as JSON, which answers a second, equally important question: did YAML understand your values the way you meant them?
It checks syntax and structure. It does not check a file against a schema, such as whether a Kubernetes Deployment has a required field; for that, use the schema validation built into your tooling.
Common YAML errors and their fixes
| Message | Typical cause | Fix |
|---|---|---|
tab characters must not be used in indentation | A tab at the start of a line | Indent with spaces only |
bad indentation of a mapping entry | A key misaligned with its siblings, or an unquoted value containing : | Align the key, or quote the value |
duplicated mapping key | The same key twice in one mapping | Remove or rename one of them |
end of the stream or a document separator is expected | Unclosed [ or {, or stray text after a value | Close the collection or remove the extra text |
Only the first error is reported, because a parser cannot reliably continue after a structural problem. Fix it and the next one, if any, appears. Example: the second line below is indented with a tab.
a: 1
b: 2
Result: Invalid YAML: tab characters must not be used in indentation (line 2, column 1).
Valid but surprising: check how values are typed
A file can pass validation and still contain values that parse differently from what you expected. The JSON output makes this visible. This parser follows the YAML 1.2 core rules:
a: yes
b: ~
k: 007
e: 12:30:00
version: 1.10
h: "1.0"
parses to:
{
"a": "yes",
"b": null,
"k": 7,
"e": "12:30:00",
"version": 1.1,
"h": "1.0"
}
Note how 007 lost its leading zeros and 1.10 became the number 1.1. Zip codes, version numbers and IDs should be quoted. Words like yes, no and on stay strings here, but older YAML 1.1 tools treat them as booleans, so quoting them is the portable choice.
Multi-document files
Streams with several documents separated by --- are validated as a whole. The output is a JSON array with one element per document, and the status bar reports the count, for example Valid YAML ✓ (2 documents) when the file starts with a separator.
Other limits to know
- Anchors and aliases (
&name/*name) are resolved, but merge keys (<<) appear as a literal<<key in the output rather than being merged. - Special floats such as
.infare valid YAML but have no JSON equivalent, so they show asnullin the JSON view.
Next steps
Once the file is valid, the YAML formatter can clean up its layout, and the YAML to JSON converter exports the data. Validating a JSON file instead? Use the JSON validator.
Privacy
Validation runs entirely in your browser. The YAML is only sent to our server if you use Load URL (to fetch a remote file) or Save & Share (to store it behind a link).
YAML validator in Python
To validate YAML in Python, parse it with PyYAML and catch yaml.YAMLError. Syntax errors arrive as MarkedYAMLError, whose problem_mark holds the position; its line and column are zero-based, so add 1 before showing them. Use safe_load_all() so that multi-document files are checked too. The thing to know is that PyYAML accepts duplicate keys silently and keeps the last value, which is why the third call below reports the document as valid.
# pip install pyyaml
import yaml
def validate(text):
try:
documents = list(yaml.safe_load_all(text))
except yaml.MarkedYAMLError as err:
mark = err.problem_mark
return f"Invalid: {err.problem} (line {mark.line + 1}, column {mark.column + 1})"
except yaml.YAMLError as err:
return f"Invalid: {err}"
return f"Valid ({len(documents)} document(s))"
print(validate("a: 1\nb: [1, 2]\n"))
print(validate("a: 1\n\tb: 2\n"))
print(validate("a: 1\na: 2\n"))
The validator above rejects that third document with “duplicated mapping key” and reports the tab error at the same line 2, column 1, so it is a useful second opinion on files that PyYAML passes.