YAML Formatter
About YAML Formatter
YAML Formatter rewrites valid YAML 1.2 into a consistent layout while retaining comments, anchors, aliases and multi-document stream boundaries wherever the YAML syntax tree can represent them.
How it works
Syntax-tree formatting
The formatter parses the source into YAML document nodes and serializes those nodes again. Comments stay attached to their nodes instead of being discarded by a YAML-to-JSON round trip.
Controlled style choices
Choose two- or four-space indentation, preserve or force string quotes, keep collection style or convert maps and sequences to block or flow notation, and set a preferred line width.
YAML 1.2 semantics
Formatting uses the YAML 1.2 core schema with strict syntax and duplicate-key checks. It changes presentation, not resolved application values.
Frequently asked questions
Are comments preserved exactly character for character?
Comment text and attachment are preserved, but surrounding whitespace can move as the document is reformatted.
Will forcing quotes affect mapping keys?
Ordinary keys retain their existing style; the selected quote style applies to scalar values.
Can it format a --- document stream?
Yes. Each document is formatted and explicit stream separators are retained.
Sources & last verified
The behaviour of this tool and the claims on this page were checked against the specifications below on . Everything runs in your browser, so the output you see is exactly what the engine produced.
Found a wrong result or an outdated claim? Report an error and it will be re-verified.