Validate YAML Online

Validate YAML online: paste your YAML code or upload a .yaml or .yml file and press Validate to check it. The built-in YAML linter highlights all syntax errors at their exact lines and columns. All checks run in your browser, and nothing is uploaded to the Internet. It's free.

About Online YAML Validator

The YAML Validator checks the syntax of YAML and shows every error at once. Use it to check a Kubernetes manifest, a docker-compose file, a GitHub Actions workflow, an Ansible playbook or an OpenAPI spec.

  • Check YAML syntax against the YAML specification
  • Show every syntax error with its line and column
  • Highlight the errors in your code with a built-in YAML linter
  • Check each document of a file split by ---
  • Accept custom tags such as !Ref and !Sub in CloudFormation templates
  • Format valid YAML into a human-readable format
  • View the YAML structure as a tree
  • Upload a .yaml or .yml file from your disk
  • Free to use

What is YAML?

YAML is a text format for configuration files and data. It shows structure with indentation instead of brackets: a key and a colon start a mapping, a dash starts a list item, and # starts a comment. YAML is a superset of JSON, and the same data can be presented in both formats; the YAML to JSON Converter converts YAML data to JSON. YAML files use the .yaml or .yml extension.

What is YAML validation?

YAML validation checks that a text follows the YAML syntax: spaces for indentation, the keys of one mapping in one column, a space after each colon and each list dash, closed quotes and brackets, unique keys, and an anchor for every alias. It does not check the meaning: a Kubernetes manifest with a misspelled field name is still valid YAML.

Why does YAML break?

In YAML, whitespace is syntax, and YAML files are edited by hand. A tab in the indentation, a key one space off, or a value with : inside it makes the file invalid. Kubernetes, Docker Compose and GitHub Actions cannot read such a file, and the deploy or the workflow fails.

How to validate YAML online?

Paste your YAML code, or press Upload to open a .yaml or .yml file, then press Validate. Valid YAML gets the line "This is a valid YAML". For invalid YAML, the result lists every error with its line and column, and the editor scrolls to the first one. Format converts valid YAML into a human-readable format and keeps its comments, as the YAML Formatter does.

How does the YAML validator work?

The page parses the YAML in your browser with the yaml package for JavaScript. The parser does not stop at the first error: it reads the whole file and reports each error with its line and column, and the linter marks the same errors in the editor. Nothing is sent to the server.

YAML Validator Example

Below is a docker-compose file with two errors: environment is indented one space less than the keys of web, and db has the key image twice. The validator reports both.

Invalid YAML Example
services:
  web:
    image: nginx:1.27
    ports:
      - "8080:80"
   environment:
      - DEBUG=1
  db:
    image: postgres
    image: mysql

YAML Validation Result
All mapping items must start at the same column at line 6, column 1:

      - "8080:80"
   environment:
^

Map keys must be unique at line 10, column 5:

    image: postgres
    image: mysql
    ^

YAML Syntax Rules

  • Indent with spaces only: a tab in the indentation is an error.
  • The keys of one mapping start at the same column.
  • A colon and a space separate a key from its value: image:nginx is one string, not a key and a value.
  • A list item is a dash and a space: -a is a string, not an item.
  • A value that contains : is quoted: msg: "a: b".
  • # starts a comment only after a space: in a: b#c, the value is b#c.
  • The keys of one mapping are unique.
  • An alias such as *defaults needs an anchor &defaults.
  • Quotes and brackets are closed.
  • Documents in one file are separated by ---.
Updated: