YAML Formatter

Normalise indentation and spacing in YAML without losing comments. Useful before committing config files or when a file has mixed indent widths.

How it works

The file is parsed into a document tree that keeps comments and key order, then printed with your indent width. Values and types are not changed.

Sequences under a key can be indented or flush with the key; both are valid YAML. The "indent sequences" option picks one style.

Everything above runs in JavaScript inside this tab. Your data is not uploaded. Inputs are remembered in this browser only so they survive a reload; you can switch that off on the privacy page.

Questions

Will my comments be kept?

Yes. Comments attached to keys and items are preserved. Comments in unusual positions may move to the nearest node.

Does it change quoting?

Plain, single- and double-quoted scalars keep their style wherever possible.