Skip to content

YAML Formatter & Validator

Re-indents YAML consistently, validates it, and flags the tab and anchor mistakes that break parsers.

Re-indents a YAML file consistently and tells you what a different parser would read differently. It is a YAML 1.2 reader that keeps comments, anchors, tags and block scalars, so the output is your document with the layout fixed — not a round trip through a data model that would have thrown your comments away.

🔒 Runs entirely in your browseryamlformatvalidateconfig
Output
Indent

YAML in

Drop a .yaml file

Read in this tab only. Nothing is uploaded.

Formatted YAML

Formatted.

Read, but parsers may disagree about these

  • 19:22 — `no` is the string "no" in YAML 1.2. A YAML 1.1 parser reads it as a boolean — quote it, or write true/false, so both agree.

Documents

1

Keys

30

List items

8

Anchors / aliases

1 / 1

Warnings

1

What this formatter does and does not do

  • · Read with the YAML 1.2 core schema. yes and no and on and off are strings, and 0755 is decimal 755, not octal. Values that a 1.1 parser would read differently are flagged as warnings above.
  • · Comments, anchors (&), aliases (*), tags and | and > block scalars are all preserved. The order of values is not changed either.
  • · Tab indentation, duplicate keys, an alias used before it is defined and an unclosed quote are all caught as errors, with a line and column.
  • · The << merge key is a 1.1 feature, but docker-compose and Ansible files use it so widely that it is applied when converting to JSON — with a warning saying so.
  • · A comment inside a flow collection like [a, b] has no line to attach to and is lost. Every other comment survives.

To convert to JSON or TOML use the JSON ⇄ YAML converter, and to check a document against a schema use the JSON Schema validator.

How to use it

  1. Paste the manifest or config

    A Kubernetes manifest, a CI file, a docker-compose. Multiple documents separated by `---` are read as a stream and counted separately.

  2. Choose the list style

    The one setting people actually argue about: whether `- item` sits level with its key or indented under it. Both are valid YAML; Kubernetes manifests conventionally use the level form.

  3. Read the warnings

    Values whose meaning depends on which YAML version the reader implements — `yes`, `no`, `0755` — are listed with a line and column. These are the ones that break a deploy on a different tool.

  4. Or switch the output to JSON

    The same parse, rendered as JSON, which is the quickest way to see what a value actually resolved to — including what a merge key expanded into.

Common questions

Why is `no` a string here?

Because the YAML 1.2 core schema says so: the only booleans are `true` and `false`. YAML 1.1 — which PyYAML still defaults to — reads `no`, `off` and `n` as false. Any value where the two disagree is flagged as a warning, because it is a real difference in behaviour, not a stylistic one.

Are my anchors and aliases preserved?

In the YAML output, yes — `&res` and `*res` come out as you wrote them, and the count is shown in the stats. The JSON view has to expand them, because JSON has no way to say "the same node again".

Does it support merge keys?

`<<:` is a YAML 1.1 feature, not part of 1.2 — but docker-compose and Ansible files use it constantly, so it is applied when converting to JSON, with a warning saying that is what happened. In the YAML output it is left exactly as written.

A comment disappeared. Why?

Almost certainly it was inside a flow collection — `[a, # note\n b]`. A flow collection is reprinted as a single line, and a comment there has no line to attach to. Every comment on its own line, or trailing a value, survives.

Feed it from

Next

These accept what this tool produces, so the result can go straight in.