YAML Formatter
Format and re-indent YAML online. Normalise indentation, collapse blank lines, sort keys and rewrite flow collections as block style, privately.
What is the YAML Formatter?
The ByteTools YAML Formatter tidies messy YAML by parsing it and printing it again from scratch. Ragged indentation is normalised to the width you choose, runs of blank lines collapse, flow collections like {a: 1} are rewritten as block style, and sequence dashes line up neatly under the key that owns them.
- Re-indents the whole document to 2, 4 or 6 spaces
- Rewrites flow collections as block style (or the reverse)
- Keeps each # comment attached to the key below it
- Optional alphabetical sorting of mapping keys
- Reports lines in, lines out and character count
- Everything runs locally — nothing is uploaded
How to use the YAML Formatter
- 1
Paste your YAML into the input box, or drop a .yml or .yaml file onto the drop zone.
- 2
Choose an indent width of 2, 4 or 6 spaces.
- 3
Tick 'Sort mapping keys A–Z', 'Compact flow style' or untick 'Keep # comments' as needed.
- 4
Click Format YAML, then Copy the tidied document or Download it as a .yaml file.
About the YAML Formatter
The ByteTools YAML Formatter tidies messy YAML by parsing it and printing it again from scratch. Ragged indentation is normalised to the width you choose, runs of blank lines collapse, flow collections like {a: 1} are rewritten as block style, and sequence dashes line up neatly under the key that owns them.
Comments are not thrown away. Each # comment line stays attached to the key or sequence item that follows it, so the notes your team left in a CI pipeline or Helm values file survive the reformat. You can also switch comments off if you want a stripped, minimal file.
Formatting runs 100% locally in your browser. Your YAML is never uploaded or stored, so pipelines, manifests and configuration containing internal hostnames or service names stay entirely on your own machine.
Frequently asked questions
How do I fix the indentation in a YAML file?
Paste the file, pick your indent width and click Format YAML. The document is re-parsed and printed again with consistent indentation, so mixed 2-space and 4-space blocks all end up the same.
Will formatting delete my comments?
No, as long as 'Keep # comments' stays ticked. Comment lines are re-attached above the key or sequence item they preceded in the original file. Comments written at the end of a value line are the one exception and are dropped.
Why did my quoted numbers stay quoted?
Because removing the quotes would change the type. A value like "01234" or "true" is a string in the original document, so the formatter keeps the quotes to preserve exactly what the file means.
Does the formatter change my data?
It changes layout, not content. The document is parsed to a value tree and printed again, so the resulting YAML parses to the same data — but purely cosmetic details like the original quoting style are normalised.
Can it sort keys alphabetically?
Yes. Tick 'Sort mapping keys A–Z' and every mapping is emitted in alphabetical order. That makes two versions of the same configuration file far easier to diff line by line.
Related tools
YAML Validator
Validate YAML online and catch the errors that break CI: tabs, bad indentation, duplicate keys, missing spaces after a colon and unclosed quotes.
YAML to JSON Converter
Convert YAML to JSON online in your browser. Handles block scalars, flow collections, anchors and multi-document files — nothing is uploaded.
JSON to YAML Converter
Convert JSON to clean block-style YAML online. Choose the indent width, sort keys, and keep numeric strings quoted — all inside your browser.
JSON Formatter
Format, beautify and minify JSON online with 2-space, 4-space or tab indentation. Sort keys alphabetically and catch syntax errors instantly — free and private.
TOML to JSON Converter
Convert TOML to JSON online. Parses TOML v1.0 tables, arrays of tables, dotted keys, dates and multi-line strings entirely inside your browser.