About the YAML Formatter & Validator tool
YAML is everywhere in modern infrastructure: Kubernetes manifests, Docker Compose files, GitHub Actions and GitLab CI workflows, Ansible playbooks and OpenAPI specs. It is also easy to break, because indentation is part of the syntax and tabs, mixed indents or a missing space after a colon cause confusing errors. This YAML formatter validates your file and rewrites it with clean, consistent indentation.
The input is parsed with js-yaml. If it is invalid, you get the parser’s reason together with the line and column where it failed. If it is valid, the data is written back out using the indent you choose, 2 or 4 spaces, with block-style lists and maps, quoting only where YAML needs it. Flow-style collections like [a, b] are expanded, inconsistent indentation is normalised, and files with several documents separated by --- are kept as separate documents.
Options let you sort keys alphabetically, prefer single or double quotes, and wrap long strings at 80 characters. Because the file is re-serialised from its data, comments are not preserved and anchors and aliases are expanded, so keep your original if comments matter. Nothing is uploaded; formatting runs in your browser.
How to use YAML Formatter & Validator
- Paste YAML into “YAML input”, open a .yaml or .yml file, or click “Load sample”.
- If an error appears, fix the line and column it reports.
- Choose the “Indent”, “Quote style” and whether to “Sort keys A–Z” or “Wrap long strings at 80”.
- Copy the “Formatted YAML” or download it.
Features
Validation with line numbers
Syntax errors show the parser’s reason and exact position.
Consistent indentation
Rewrites the whole file with 2 or 4 spaces and block-style collections.
Multi-document support
Files with several --- separated documents are formatted document by document.
Key sorting and quoting
Optional alphabetical keys and a choice of single or double quotes.
When to use it
- Fix indentation in a Kubernetes manifest before kubectl apply.
- Validate a GitHub Actions workflow that fails with a parse error.
- Normalise Docker Compose files written by different team members.
- Tidy an OpenAPI YAML specification before code review.
Frequently asked questions
Why are my comments removed?
The formatter parses YAML into data and writes it back out. Comments are not part of the data model, so they are lost. Keep a copy of your original if comments are important.
Can YAML use tabs for indentation?
No. The YAML specification forbids tabs for indentation, which is a common cause of errors. The formatted output always uses spaces.
Does it validate Kubernetes or GitHub Actions schemas?
No. It checks YAML syntax only. A file can be valid YAML and still have a wrong key for Kubernetes or Actions.
What happens to anchors and aliases?
Aliases (*name) are expanded into full copies of the anchored data, so the output is longer but equivalent.
Why did yes or on get quotes?
Some YAML parsers treat unquoted yes, no, on and off as booleans. The formatter quotes such strings so every parser reads them as text.