YAML Formatter
Format messy YAML with consistent indentation, expand inline {} and [] collections and optionally sort keys. Validates as it formats. Free and in-browser.
Runs in your browser. Nothing is uploaded.
About YAML Formatter
YAML Formatter parses your YAML and writes it back out in one consistent style: the indent you choose, block-style mappings and lists, and inline {a: 1} or [x, y] collections expanded onto their own lines. Mixed indentation, the most common cause of broken YAML, disappears.
Because it fully parses the input first, the formatter doubles as a validator: if the YAML is invalid, you see the line and column instead of output. Multi-document files keep their --- separators.
One honest limitation: comments are not preserved, because the document is rebuilt from the parsed data. Format a copy if your comments matter.
How to use YAML Formatter
- Type or paste your text into the input box. Press Sample to see an example.
- Adjust the options. The result updates as you type.
- Copy the result, or press Use as input to chain another transformation.
Frequently asked questions
Does it keep my comments?
No. The YAML is parsed and re-written from the data, and comments are not part of the data. Keep a copy if you need them.
2 or 4 spaces?
2 spaces is the convention for Kubernetes, Docker Compose and GitHub Actions. Either is valid as long as a file is consistent.
Is YAML Formatter free and private?
Yes. YAML Formatter is completely free with no sign-up. Everything runs in your browser, so whatever you type or paste never leaves your device.