YAML Formatter
Normalize YAML indentation and spacing while keeping your comments intact.
Conversion payloads stay in this browser tab and are never placed in page URLs - see how local processing works. Privacy-safe analytics record only the tool, outcome, and a coarse input-size bucket. Press Cmd/Ctrl + Enter to convert.
How to Format YAML
Paste YAML with inconsistent indentation or ragged alignment and the formatter re-emits it with uniform two-space nesting. Because the document is parsed before it is printed, anything the formatter returns is guaranteed to parse - and if the input does not parse, you get an exact location instead of mangled output.
Indentation Rules YAML Enforces
YAML's whitespace rules cause more configuration bugs than its type system. Tabs are illegal for indentation. Every key in a mapping must begin at the same column. A list item's dash may sit at its parent key's column or be indented further, but the choice has to stay consistent within the block. Formatting a file before committing it makes an accidental violation visible in review rather than in a failed pipeline.
Frequently Asked Questions
Are my comments preserved?
Yes. The formatter works through the YAML document model rather than converting to JSON and back, so comments stay attached to the keys and list items they document. Any formatter that round-trips through JSON deletes every comment in the file.
What exactly gets reformatted?
Indentation is normalized to two spaces per level, extra spaces after a key's colon are collapsed to one, and trailing blank lines are trimmed. Scalar values, quoting that is required for correctness, key order, and anchors are left alone.
Can it fix broken YAML?
No - it formats YAML that already parses. If the document has a syntax error you get the line and column instead of a guess, because inferring the intended indentation of a broken YAML block is exactly the kind of silent rewrite that corrupts configuration.
Does it change how my values are typed?
No. The formatter does not requote scalars, so a value like "3.10" stays a quoted string and 3.10 stays a number. That distinction matters for image tags and version fields, where losing the quotes changes the meaning.
Related Tools
YAML Validator
Validate YAML with exact line and column errors, plus the warnings a pass/fail check hides.
JSON to YAML Converter
Validate JSON, control YAML formatting, compare option changes, and export configuration-ready output locally in your browser.
YAML to JSON Converter
Convert YAML to JSON instantly with our free online tool.