YAML Formatter & Validator
Format and validate YAML with consistent indentation.
By opening this website or using its tools, you agree to our Terms and Privacy Policy.
Your file never leaves your browser during processing
How it works
To format YAML, paste it above — it is parsed and re-written with consistent indentation instantly in your browser, with a specific error message if the document isn’t valid YAML.
YAML is indentation-sensitive in a way JSON isn’t — the same data can be written with inconsistent spacing that still parses, but reads inconsistently between files, or one wrong space can break parsing entirely with an error that doesn’t obviously point at the real problem. This tool parses the document into a plain JavaScript value and re-serializes it with consistent, chosen indentation, which normalizes spacing regardless of how the original was formatted.
Parsing and re-serializing is handled by the `yaml` library rather than a hand-written parser — unlike this site’s CSV parser, YAML’s spec covers enough (anchors and aliases, multiple document styles, flow vs. block collections, implicit typing of scalars like dates and booleans) that a hand-rolled parser would either be incomplete or nearly as large as an established one, so reuse was the right call here.
When a document fails to parse, the error message comes directly from the parser and generally includes a line number, since YAML errors are usually structural (bad indentation, an unclosed flow collection) rather than a single bad character the way a JSON syntax error tends to be.
FAQ
Why does YAML break more easily than JSON when I mistype something?
YAML uses indentation to express structure instead of explicit braces and brackets, so a single misplaced space can change what a line means rather than causing an obvious syntax error.
Does this preserve comments in my YAML?
No — parsing into a plain value and re-serializing it drops comments, the same tradeoff most format-and-validate tools make. If preserving comments matters, treat this as a validation check rather than a round-trip formatter.
What YAML features are supported?
Everything the `yaml` package supports: block and flow collections, anchors and aliases, multi-document streams, and standard scalar types like numbers, booleans, and dates.