OnlineTextLab
Esc

YAML Validator

A line-numbered verdict on your YAML, and the data as a parser sees it, so surprises show.

How a parser reads it

See the verdict here, then the data as a parser reads it, so type surprises show up.

Runs on your device. Your files and text are not uploaded.

About YAML Validator

YAML's trouble is rarely that a file fails to load. It is that the file loads and means something else. DEBUG: no might be a string or a boolean depending on the parser, 0755 might be 755 or 493, and a list indented one space too far becomes something you did not write.

So beyond saying whether the file is valid, this tool shows you what the parser got, written out as JSON, where every string has quotes and every number does not. Compose files, CI workflows, Kubernetes manifests and app configs are what it is built around.

How it works

A YAML reader written for this page handles what configuration files really use: block and flow collections, quoted, plain and block scalars, comments, multiple documents, anchors, aliases and << merge keys. Types follow the YAML 1.2 core schema, and every error carries its line number. Repeated keys are errors, as are tabs used for indentation.

Where YAML 1.1 and 1.2 disagree, you get a warning instead of silence. Yes and no words, numbers with a leading zero and base-60 values such as 22:22 each mean one thing in this schema and another in older parsers such as PyYAML, so the warning tells you to add quotes. Aliases are also counted while they expand, which stops a billion-laughs file from freezing the tab.

How to use YAML Validator

  1. Paste into the YAML to check box, or press Upload to open a .yaml or .yml file. Try an example loads a Compose file.
  2. Read the verdict at the top. An error gives the line and what to change, and a pass names the shape, such as a mapping with 2 keys.
  3. Compare the How a parser reads it pane with what you meant. Warnings appear above it.
  4. Press Copy, or Download to save the JSON as parsed-yaml.json.

Three values that older parsers read differently

Input
services:
  web:
    image: nginx:1.25
    ports:
      - 8080:80
      - 22:22
    environment:
      DEBUG: no
      MODE: 0755
Output
Valid YAML: mapping with 1 key

Worth checking:
- Line 6: 22:22 is a string in YAML 1.2, but YAML 1.1 parsers read it as a base-60 number. Put it in quotes.
- Line 8: "no" is a string in YAML 1.2, but older parsers such as PyYAML read it as a boolean. Put it in quotes if you mean text, or use true or false.
- Line 9: 0755 is the number 755 in YAML 1.2, but YAML 1.1 parsers read it as octal 493. Put it in quotes if the leading zero matters.

The file is valid, and yet all three lines can behave differently on another machine. This is the base-60 trap that has broken port mappings in Compose files.

When it helps

  • Checking a GitHub Actions or GitLab CI workflow after a hand edit, before pushing it
  • Working out why a Compose environment value arrives as false when you wrote no
  • Seeing what an anchor and merge key expand to in a repetitive config
  • Reading a pipeline file as JSON to confirm which level a setting ended up on

Tips for a better result

  • When a setting seems to be ignored, look at its nesting in the JSON pane. A wrong indent often moves it under a different parent without any error.
  • If the verdict says the whole file is one long string, you probably wrote key:value. YAML needs the space after the colon.
  • Quoting is cheap and removes all doubt. For version numbers, ports and anything with a leading zero, quote the value.

Good to know

  • It checks YAML syntax, not meaning. It cannot tell you whether a Kubernetes manifest has the right fields for its kind.
  • Explicit keys written with ? are valid YAML but are not read here, so such a file gets an error rather than a false pass.
  • Custom tags are read as ordinary values, so anything a tag would do in your application, such as CloudFormation's !Ref, is not applied.
  • Results follow YAML 1.2. Your own parser might use 1.1 rules, which is what the warnings are for.

Questions people ask

Is YAML a superset of JSON?

Since version 1.2, almost. Nearly all JSON documents are also valid YAML, so you can paste JSON here and get a pass.

Why can't I indent with tabs?

The YAML specification forbids tabs for indentation, because their width varies between editors and nesting depends on exact columns. Replace them with spaces, and the error names the line to fix.

What happens with a file that has several documents?

Documents separated by --- are all read, and the JSON pane shows them as an array with one entry for each.

Why does my key need quotes?

Plain values cannot start with some characters, such as @, % or a backtick, and a value containing : reads as a nested key. Quotes make the whole thing plain text.

What to use next

Learn more

Last reviewed . Read our editorial policy.