Help

YAML Validator

Paste YAML and this validator checks it as you type, then explains each syntax error in plain English with the line and column. It catches tab indentation, duplicate keys, unclosed quotes and brackets, and invisible no-break spaces that look like indentation but are not. Turn on Format YAML to get a tidy copy. The YAML is checked in your browser and never uploaded.


How to validate YAML online

  1. Paste your YAML into the YAML box, or type it. There is no Validate button: the text is checked live.
  2. Pasted text is checked at once. When you type, the check runs about a quarter of a second after your last key, a little longer for very large text. The previous result stays dimmed until the new one arrives.
  3. Read the box under the editor. A green Valid YAML box means the syntax is correct. A red Invalid YAML box (or Invalid YAML: N problems) lists what is wrong.
  4. Each problem gives a sentence, Line N, column M, and a snippet of the line with line numbers, two lines above and one below, and a caret under the column.
  5. Press Show in editor to select that line in the box, fix it, and watch the box turn green.

Only the first syntax error of each document is reported. The errors after it are usually side effects, such as a missing quote swallowing the lines below. Duplicate keys and undefined aliases are always all listed, and up to 20 problems are shown.

Common YAML errors and how to fix them

Each error is explained in a sentence instead of a raw parser message. These are the ones people run into most:

What the validator saysUsual causeFix
This line is indented with a tab. YAML only allows spaces for indentation.An editor inserted a tab, or a tab came with the pasteReplace the tab with spaces
This line does not line up with the other keys of its mapping.One key has one space more or less than its siblingsGive keys at the same level the same indent
The indentation is wrong here.A nested block is not indented deeper than its parentIndent the child further than the parent key
The key a appears more than once in the same mapping.A copied block left a repeated keyMerge or delete the duplicate
This line is not a key: value pair.A missing colon, or a wrapped line that is not indentedAdd : after the key, or indent the continuation
A key: value pair cannot be written inside another one on the same line.A second colon in a plain value, as in a: b: cPut the value in quotes or use a new indented line
This [ is never closed with a ], or the lines inside it are not indented enough.A missing bracket; the message points at the line where it openedAdd the closing bracket or brace
This quoted text never ends.A missing closing quote; the message points at the line where it openedAdd the closing quote
A comma is missing between items inside [ ] or { }.Two items run together in a flow list or mappingAdd the comma
A value cannot start with @ unless it is in quotes.A value beginning with @ or a backtickPut the value in quotes
A # only starts a comment when a space comes before it.A # stuck to the word before itAdd the space, or quote the text
\q is not a valid escape in double quotes.A backslash in a double-quoted string, such as a Windows pathWrite \\, or use single quotes
The alias *name points to an anchor &name that is not defined above it.An alias with no anchor before itDefine &name earlier in the file
This part does not fit here.Often a - item list mixed with key: value lines at the same level, or something unfinished on the line abovePut the list under its own key, and check the line above
This % directive at the top of the document is not valid or not supported.A line starting with % before the documentRemove it, or use %YAML or %TAG correctly

What those parser messages mean

If you landed here from an error in your terminal or CI log, this is how the common wordings map to what this validator reports. Paste the same file and it shows the line.

Message from another toolWhat it usually is
found character that cannot start any token while scanning for the next tokenA tab at the start of a line, or a value starting with @ or a backtick
tabs are not allowed for indentA tab used as indentation
mapping values are not allowed hereA second colon on one line, such as a: b: c, an unquoted value that contains : , or a line indented under a key that already has a value
did not find expected keyA line that does not line up with the other keys of its mapping
bad indentation of a mapping entryA key indented to the wrong depth
could not find expected ':'A line with no colon after the key

Wording differs between parsers (PyYAML, js-yaml, Ruby, Go, the Home Assistant and ESPHome loaders), and a parser often reports a line below the real mistake. This validator points at the line it can show you.

Tabs and invisible characters

The two hardest YAML mistakes to spot are the ones you cannot see. This validator makes them visible:

Looks like an indented key, parses, but is not server:
port: 8080
  host: example.com

In that sample the last line starts with two no-break spaces instead of two spaces, so YAML reads it as a separate top-level key and host is not a child of server. The yellow box names the character and the line.

Format YAML

Turn on the Format YAML switch above the box. It is off by default. When the text is valid, a Formatted YAML block appears with a Copy button above it, which changes to Copied when it has copied. Formatting is predictable:

Formatting works on valid YAML only, so it cannot repair a broken file: fix the errors first. Very long output is shown cut off after 600,000 characters, and Copy still copies all of it.

YAML for GitHub Actions, Docker Compose, Kubernetes and more

The check is the same whatever the YAML is for, so it works on GitHub Actions workflows, docker-compose.yml, Kubernetes manifests and Helm values, OpenAPI files, Ansible playbooks, Home Assistant configuration, CloudFormation templates and mkdocs configuration. Paste the file before you commit or push and the syntax errors show up without waiting for a CI run.

Large YAML files

The check runs in a Web Worker in your browser. Typical config, CI and Kubernetes files are checked in a blink. The limit is 5,000,000 characters, and a text near it takes a few seconds and a lot of memory. Over the limit you are asked to paste a smaller piece.

What this validator does not check

It checks YAML syntax only. It does not know what a given tool expects, so Kubernetes fields, GitHub Actions or Docker Compose keys and JSON Schema rules are not checked, and a misspelled key name still passes. It follows YAML 1.2, so the YAML 1.1 words yes, no, on and off are plain text and never judged. It does not run, fetch or load anything, and a lone old-Mac carriage return is not treated as a line break.

More tools for structured data

Working with other formats? Tidy and check JSON with the JSON Formatter, check it against a schema with the JSON Schema Validator, or check markup with the XML Validator. Matching a pattern in your config? Try it in the Regex Tester.


Frequently asked questions

How do I validate YAML online?

Paste your YAML into the YAML box. The text is checked as you paste or type, so there is no button to press. A green Valid YAML box means the syntax is correct. A red Invalid YAML box gives each problem in plain English with Line N, column M and a snippet of the line.

Why does YAML say tabs are not allowed for indent?

YAML only allows spaces for indentation, and a tab character at the start of a line is a syntax error. Editors often insert tabs when you press Tab, or paste them in from another file. This validator draws a tab as an arrow in the snippet and says: This line is indented with a tab. YAML only allows spaces for indentation. Replace the tab with spaces.

What does "mapping values are not allowed here" mean in YAML?

Most often a second colon on a line that already has a key, as in a: b: c, an unquoted value that contains a colon and a space, or a line indented under a key that already has a value. Parsers such as PyYAML and Home Assistant use this wording. This validator says: A key: value pair cannot be written inside another one on the same line. Put the inner pair on its own indented line, or put the value in quotes.

What does "did not find expected key" mean in YAML?

A line in a mapping does not start in the same column as the other keys at its level, or a line that should be a key is not one. Check the indentation of the line it names and the line above it. This validator reports it as a line that does not line up with the other keys of its mapping, or as a line that is not a key: value pair.

What does "bad indentation of a mapping entry" mean in YAML?

A nested key is indented to the wrong depth: not deeper than its parent, or a different number of spaces from its siblings. Give every key at the same level the same number of spaces and indent children further than their parent. This validator usually says: This line does not line up with the other keys of its mapping. Keys at the same level must start in the same column.

What does "found character that cannot start any token" mean in YAML?

When the character is a tab, it is the tab-indentation error: the parser met a tab where it expected a key or a value. Replace the tab with spaces. A line that starts with @ or a backtick causes it too, because a value cannot begin with those characters unless it is in quotes.

How do I find duplicate keys in YAML?

Paste the YAML. A key that appears twice in the same mapping is reported as invalid, with a message such as The key a appears more than once in the same mapping, and every duplicate is listed with its own line and column. Many parsers silently keep only the last value, so a repeated key can hide a setting.

Why does a valid YAML file show "Valid, but check this line"?

A line starts with an invisible space, usually a no-break space (U+00A0) pasted from a web page or a chat app. YAML reads it as part of the text instead of as indentation, so the line is not really indented even though the file parses. The yellow box names the character and its column. Delete it and type ordinary spaces.

Can I validate a GitHub Actions, Docker Compose or Kubernetes YAML file here?

Yes for the syntax: indentation, quotes, brackets, duplicate keys and the other errors this page lists. No for the meaning. It does not know which keys GitHub Actions, Docker Compose, Kubernetes, Helm or OpenAPI allow, so a misspelled field name still passes. Tags such as CloudFormation !Ref and !Sub and GitLab !reference are accepted.

Does YAML allow several documents in one file?

Yes. Documents are separated by a line with three dashes, ---, as in Kubernetes manifests. This validator checks each document on its own, tells you how many it found, and reports a syntax error in each document that has one.

How do I format YAML or fix its indentation online?

Turn on the Format YAML switch. When the YAML is valid, a Formatted YAML block appears with a Copy button. It uses 2-space indentation, keeps comments, anchors, aliases, quote styles and key order, and never wraps long lines. Formatting only works on valid YAML, so fix the reported errors first.

Are yes, no, on and off booleans in this validator?

No. It follows YAML 1.2, where yes, no, on and off are plain text. Older YAML 1.1 parsers read them as booleans, which is why a country code such as NO can turn into false in some tools. This validator checks syntax only, so it does not flag them either way.

How large a YAML file can I check?

Up to 5,000,000 characters. Ordinary config, CI and Kubernetes files are checked in a blink. A text close to the limit takes a few seconds and a lot of memory. Over the limit you are asked to paste a smaller piece.

Is my YAML uploaded when I validate it?

No. The YAML is parsed in your browser, in a background worker, and nothing is uploaded or saved. Configuration files often hold hostnames and tokens, so check that you have removed real secrets before you share a screenshot of the result.


Recommended

Helps keep the tools free. ✨

Images are for illustration only. As an Amazon Associate I earn from qualifying purchases.