YAML Validator and Formatter

Check YAML for syntax errors as you type, then rewrite it with consistent indentation. Errors show the line and column with a hint for the usual culprits: tabs, bad indentation, and stray colons.

Updated
Runs in your browser. Your data is not uploaded.
Checks as you type for inputs up to 200 KB. Convert to JSON

How to use the YAML Validator

  1. Paste YAML into YAML input, or upload or drop a .yaml or .yml file. It is checked as you type.
  2. If there is an error, fix the line shown under the input. If the YAML is valid, you see how many documents it has and the type of each root.
  3. To tidy it, choose the Indent and Sort keys option and press Format, then copy or download the result.

How it works

The input is parsed with js-yaml using the YAML 1.2 core schema, the same rules most modern tools follow.

  • Every document in the file is read. Documents are separated by --- lines.
  • An error stops at the first problem and reports its line and column. Tabs in indentation, keys at an unexpected indent, duplicate keys, and unclosed quotes are all errors.
  • Format writes the parsed data back as YAML with the chosen indent. Anchors and aliases are expanded, and strings are quoted only where YAML needs it.

Examples

  • name: web
      image: nginx
    is invalid: image is indented more than name but name already has a value. Fix: line the keys up.
  • title: Error: not found is invalid, because the second : starts another mapping. Fix: quote the value, title: "Error: not found".
  • A key that appears twice in the same mapping, such as port on two lines, gives a duplicated mapping key error.
  • services: {web: {ports: [80, 443]}} is valid, and formatting with 2 spaces gives:
    services:
      web:
        ports:
          - 80
          - 443

Limitations

  • Formatting removes comments, because they are not part of the parsed data. Keep a copy if the comments matter.
  • The check covers YAML syntax only. It doesn't know the rules of a Kubernetes manifest, a Compose file, or a GitHub Actions workflow.
  • Custom tags such as !Ref and !Sub in CloudFormation, or !reference in GitLab CI, are reported as unknown tags.
  • Files are limited to 5 MB.

Frequently asked questions

Can I use tabs in YAML?

Not for indentation. YAML only allows spaces there. Tabs are fine inside quoted strings.

Why is 'no' turned into false?

Older YAML 1.1 parsers read yes, no, on, and off as booleans. This tool uses YAML 1.2, where only true and false are booleans, but it quotes such words when formatting so older tools read them as text too.

Does formatting keep my comments?

No. Comments are dropped when the YAML is rewritten. Validation alone never changes your input.

Is my YAML uploaded?

No. It is checked and formatted in your browser.

Often used together with the YAML Validator & Formatter.