YAML Validator

Validate YAML with the line number of every problem — including the ones parsers accept silently: tab indentation, duplicate keys and uneven indents.

1Lines
0Keys
1Deepest nesting
0Lines with tab indentation

Everything you type here is processed on your own device. No input is sent to a server, logged, or stored.

What the YAML Validator does

Use this YAML validator to validate YAML with the line number of every problem — including the ones parsers accept silently: tab indentation, duplicate keys and uneven indents. Paste your text in, pick the options you need, and copy the result straight back out. It is most often used for finding why a CI, Docker Compose or Kubernetes file will not parse. Companion tools to this one live on FreeToolStation.org.

How to use it

  1. Paste your YAML into the box.
  2. Read the errors and warnings, each with its line number.
  3. Fix the tabs first — they are the commonest cause and the hardest to see.

How it works

YAML’s whole syntax is whitespace, which is why its errors are so hard to spot by eye. The single commonest mistake is a tab character in the indentation: YAML forbids tabs there outright, editors insert them by default, and the file looks perfectly aligned on screen. A parser rejects it with a message about the structure rather than the tab, which sends people looking in the wrong place. This checker names the line and says what it found.

Duplicate keys are the mistake that costs the most, because nothing complains. Set the same key twice at the same level and almost every YAML parser keeps the last one and silently discards the earlier value — so a config file with `port: 8080` near the top and `port: 3000` two hundred lines down listens on 3000, and nothing anywhere says why. That is reported here as a warning rather than an error, because it is technically legal, but it is almost never intentional.

A missing space after a colon is the third frequent one. YAML needs `key: value` with the space; `key:value` is not a mapping at all, it is the single string "key:value". That parses without error and produces a structure your application will not recognise. URLs are the exception that proves the rule — `url: https://example.com` is fine because the colon in the scheme is inside the value, which is why a naive check flags it wrongly and why this one does not.

Inconsistent indent widths are legal and almost always wrong. YAML cares only that nesting is deeper, not by how much, so a file mixing two and three spaces parses happily into a structure that does not match what the indentation looks like. Pick a width, usually two spaces, and keep it.

One honest limit: this checks syntax, not meaning. It cannot know whether your keys are the ones your application reads, whether a value should be a string or a number, or whether the file matches a schema. For that you need the application itself or a schema validator. What it does is find the class of error that makes a YAML file fail to parse at all, and name the line.

When to use it

  • Finding why a CI, Docker Compose or Kubernetes file will not parse.
  • Locating a tab character in indentation that looks correct on screen.
  • Catching a duplicate key that is silently overriding an earlier value.
  • Checking a config file before committing it.
  • Teaching YAML’s whitespace rules with real error messages.

Common mistakes to avoid

  • Indenting with tabs. YAML forbids it, and the file looks fine in the editor.
  • Setting the same key twice. The last one wins and nothing warns you.
  • Writing key:value with no space. It parses as one string rather than a mapping.
  • Mixing indent widths, which parses into a structure the indentation does not suggest.
  • Assuming a file that parses is correct. Syntax validity says nothing about whether the keys are right.

Frequently asked questions

Why does my YAML say "found character that cannot start any token"?

That message almost always means a tab character in the indentation. YAML does not allow tabs for indentation, and the error does not mention tabs, which is what makes it so confusing. Replace them with spaces.

Can YAML have duplicate keys?

It parses, and most implementations keep the last value and discard the earlier one without any warning. It is legal and almost never what anyone intended, so it is reported here.

Does YAML require two-space indentation?

No — it only requires that nested content is indented further than its parent. Any consistent width works. Mixing widths is legal and produces structures that do not match what the file looks like, which is why consistency is worth enforcing.

Is "key:value" without a space valid?

It is valid text but it is not a mapping. YAML reads it as the single string "key:value", so your application sees nothing with that key. The space after the colon is required.

Does this validate against a schema?

No. It checks syntax and reports the structural errors and the legal-but-wrong patterns. Whether the keys and values are the ones your application needs is a separate question that only a schema or the application can answer.

Related tools

See all developer tools →