YAML Formatter & Validator
Pretty-print, validate and re-indent YAML — multi-document files supported.
Quick answer: YAML Formatter & Validator: pretty-print, validate and re-indent YAML — multi-document files supported. Runs entirely in your browser, free, no signup.
Last updated
Good to know
YAML's whole appeal is human readability, and that hinges entirely on indentation — a single stray space can move a key into the wrong parent and change the meaning of a Kubernetes manifest or a CI workflow without any visible error. Running a file through this formatter re-emits it with consistent indentation and no trailing whitespace, so structural mistakes that were hiding in ragged spacing become obvious.
It validates as it goes: if the document can't be parsed, you have a real structural problem to fix before deploying, which is far cheaper to catch here than in a failed pipeline run. Multi-document files separated by --- are handled correctly, with each document parsed and re-emitted on its own — the common shape for Kubernetes bundles.
The trade-off to know about is comments. The standard JavaScript YAML parser treats data as data, and comments aren't part of the data model, so they are dropped on reformat. If your YAML relies on inline documentation, keep a commented master copy or use a comment-preserving desktop formatter for that file.
Don't be surprised when some strings come back quoted — values that look like booleans, versions, or that start with a dash need quoting to stay valid, and the emitter adds quotes only where the spec demands. To move the data into JSON, hand it to the JSON ↔ YAML converter.
Frequently asked questions
- Which YAML version do you support?
- YAML 1.2 via js-yaml, plus YAML 1.1 quirks where they don't conflict (e.g. boolean shorthand). Anchors and aliases are preserved.
- Will my comments survive formatting?
- No — js-yaml drops comments because YAML's spec doesn't model them as part of the data structure. If you need to preserve comments, use a desktop tool like prettier-plugin-yaml.
- How do you handle multi-document files?
- Each document is parsed and re-emitted separately, with <code>---</code> separators between them. The structure of each document is fully preserved.
- Are my files uploaded?
- No — js-yaml runs entirely in your browser.
- Why does it re-quote some of my strings?
- Strings that contain special characters (colons, leading dashes, version-like numbers) need quoting per the YAML spec — js-yaml adds quotes only where necessary to keep the file valid.