Skip to content
AZ Tools

YAML Formatter & Validator

Pretty-print and validate YAML — fix indentation, sort keys, choose line width, catch errors in place.

● Valid
Formatted

How to use

  1. Paste your YAML in the input.
  2. Tweak indent, line width, sort keys, or expand anchors.
  3. Read the formatted output and copy.

About this tool

Show

Paste any YAML and get a clean re-emitted version: consistent indentation, a line width you choose, optional alphabetical key sorting and optional expansion of anchors and references. Errors come back with the parser's own line and column, which is usually enough to find the stray tab or the misaligned dash without hunting. Because the document is parsed into data and written out again, the output is normalised rather than patched — quoting is made consistent and structure is rebuilt. That is what makes it useful on hand-edited GitHub Actions workflows, Kubernetes manifests and framework configs that have drifted, and it is also the reason comments do not survive: they are not part of YAML's data model. Everything runs locally in your browser.

Frequently asked questions

What YAML version is supported?

YAML 1.2 via js-yaml — the same parser used in many CI tools. Anchors (&) and references (*) are accepted; merge keys (<<: *anchor) are always merged into the mapping that uses them.

Are comments preserved?

No. js-yaml drops comments because the YAML spec doesn't attach them to nodes. If your YAML has critical comments, format a section at a time and paste comments back manually.

What does 'expand anchors' do?

When on, the formatter inlines anchored values everywhere they're referenced, so the output has no & / * markers. Off writes a shared object as an anchor and reference again, but under a generated name such as ref_0, and an aliased scalar still comes out in full.

Why is the line width 100 by default?

100 columns is a common compromise for reviewing code and config — wide enough for most inline scalars without word-wrapping in diffs.

Does the 'Norway problem' happen here — does NO become false?

No, and this is worth knowing: that behaviour belongs to YAML 1.1. Under the YAML 1.2 core schema this parser uses, only true and false are booleans, so no, yes, on and off all stay strings and a country column of NO survives intact. The caveat is that not every tool has moved: PyYAML's default loader is still 1.1, so a file that round-trips correctly here can still flip on the other side. That is why the formatter emits 'yes' in quotes — the quoting protects the value from readers that are stricter about it than this one.

Why did my version number 1.10 turn into 1.1?

Because unquoted 1.10 is a float, and 1.10 and 1.1 are the same float. Version strings, phone numbers with leading zeros, and part codes all need quotes to survive: write "1.10". The related trap is octal — YAML 1.2 dropped the bare leading-zero form, so a file mode written as 0755 parses as the decimal number 755, not 493. Write 0o755 if you mean octal, or quote it if you mean the literal text.

Related tools