FormatterHQ

YAML Validator

Check a YAML file before it breaks a deployment. Errors are pinpointed by line and column, and valid files are shown as the JSON data a parser actually sees.

Input YAML
Output JSON
Ready.

How to use the YAML Validator

  1. Paste the YAML into the input editor, drop a .yaml/.yml file on it, or use Load URL.
  2. Click Validate. With Auto update on, the check re-runs as you type.
  3. Read the status bar: Valid YAML ✓ with the parsed data in the output, or an error with its line and column.
  4. Optionally choose the Indent for the JSON output, or click Format to tidy the YAML itself.

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

MessageTypical causeFix
tab characters must not be used in indentationA tab at the start of a lineIndent with spaces only
bad indentation of a mapping entryA key misaligned with its siblings, or an unquoted value containing : Align the key, or quote the value
duplicated mapping keyThe same key twice in one mappingRemove or rename one of them
end of the stream or a document separator is expectedUnclosed [ or {, or stray text after a valueClose 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 .inf are valid YAML but have no JSON equivalent, so they show as null in 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.

Frequently asked questions

Does the YAML validator check Kubernetes or Docker Compose schemas?
No. It checks YAML syntax and shows the parsed data. Whether the fields are correct for a specific tool is a schema question that tools such as kubectl or docker compose config answer.
Why does "on: yes" parse as a string?
The parser follows YAML 1.2, where only true and false are booleans. YAML 1.1 parsers treat yes, no, on and off as booleans. Quote such values, or use true and false, so every tool reads them the same way.
Why did my version number 1.10 turn into 1.1?
Unquoted, 1.10 is a floating-point number, and 1.10 equals 1.1. Write "1.10" in quotes to keep it as text.
How do I find which line has the error?
The status bar shows the line and column of the first error. Fix it and the validator re-checks automatically when Auto update is on, revealing the next problem if there is one.
Can I validate several YAML documents in one file?
Yes. Documents separated by --- are all parsed, and valid output is an array containing each document.

Last updated October 3, 2026

Guides

Related tools

Credit Card Validator Check credit card numbers with the Luhn algorithm, detect Visa, Mastercard, Amex and more, and verify length. Runs 100% locally. CSS Validator Validate CSS online: find unclosed braces, missing semicolons and other syntax errors. Email Address Validator Check email address syntax in bulk and flag typos in popular domains, disposable providers, role accounts and duplicates. HTML Validator Validate HTML markup online and find unclosed, mismatched or malformed tags. IBAN Validator Validate IBANs for 80+ countries with the MOD-97 checksum and country length rules, and see bank code and account parts. ISBN Validator & Converter Validate ISBN-10 and ISBN-13 check digits and convert between the two formats, one or many at a time. YAML Viewer View YAML as an interactive tree and table. Explore nested maps and lists and see how every value is parsed. YAML Beautifier Clean up messy Kubernetes, Compose and CI YAML: consistent indentation and spacing, with comments and anchors kept as written. YAML Editor Edit YAML online with syntax highlighting, live validation and a tree preview. Format and download your file when done. YAML Formatter Format YAML online with consistent indentation while keeping comments. Validate syntax and see the exact line of any error. YAML Parser Parse YAML online and see the resulting data as JSON and a tree. Check types, anchors and multi-document files. YAML Pretty Print Pretty print YAML online and see the yq, PyYAML and js-yaml settings that give the same block style, key order and indent.