YAML Formatter

Tidy up messy YAML: consistent two-space indentation, aligned sequences, normalised quotes and spacing. Comments, anchors, and block scalars are all preserved.

More ways to experience Recasely:

Ym

Clean Up YAML Indentation and Spacing

YAML is whitespace-significant, which makes inconsistent indentation more than an aesthetic problem — it changes what the file means. This formatter rewrites a document to two-space indentation throughout, aligns sequences under their keys, and normalises quoting and spacing. It runs entirely in your browser.

Does it keep my comments?

Yes, and that is the main reason it works the way it does. Most YAML tools parse a document into data and write it back out, which silently deletes every comment, expands anchors into duplicated values, and rewrites block scalars — because none of those exist in the parsed data. This formatter rewrites the lines in place instead, so comments, anchors and aliases, block scalars, flow style, and multi-document markers all survive exactly as written.

What gets normalised?

BeforeAfter
Four- or three-space indentsTwo spaces per level
items: then a flush - aSequence indented under its key
name:    projectname: project
'single quoted'"double quoted"
[1,2,3][1, 2, 3]
{a: 1}{ a: 1 }
Several blank linesExactly one

Why is my sequence indented now?

Both forms are valid YAML and mean the same thing — a sequence may sit flush with its parent key or be indented under it. Indenting is the more common convention because it makes the nesting visible, so that is what the formatter produces. Nothing about your data changes.

Why weren't my values converted or quoted?

Because this is a formatter, not a converter: it rewrites layout and leaves values alone. NO stays NO and yes stays yes, even though older YAML parsers read those as booleans. If you want that protection applied, run the file through the JSON to YAML Converter, which re-emits values with defensive quoting.

Related tools

To move between formats, use the JSON to YAML Converter. For other structured formats see the JSON Formatter & Minifier and the XML Formatter.

Last reviewed: August 2026