YAML Formatter
Normalise the indentation of a YAML file — including one that has been edited by three different tools — while keeping the comments that explain it.
Input
YAML- characters
- 0
- lines
- 0
- size
- 0 B
Options
About this tool
YAML files accumulate inconsistent indentation faster than most formats, because the whitespace is both the syntax and the styling. A Helm chart or a CI config that several people have edited will typically have two-space blocks next to four-space blocks, and lists indented under their key in one place and level with it in another. All of it parses; none of it reads well.
Formatting here goes through the document tree rather than through a plain value, which is what makes it safe to run on a real config file: comments survive. A round trip that parsed to an object and re-emitted it would drop every comment in the file, and in a deployment manifest the comments are frequently the only documentation there is.
Multi-document streams are handled as streams. Every document between separators is formatted and all of them come back, which is the behaviour a Kubernetes manifest needs.
How to use this tool
Paste YAML, or upload a .yaml or .yml file.
Set the indent width and, if you want lines wrapped, a wrap column.
Turn on "Sort keys alphabetically" if you want a stable order for diffing.
Press Format, then copy or download the result.
Key features
- Comments preserved, including trailing comments on a line
- Every document in a multi-document stream formatted and returned
- Configurable indent width and line-wrap column
- Optional recursive alphabetical key sorting, leaving list order untouched
- Anchors and aliases left intact rather than expanded
- Indentation and tab errors reported with a line and a column
Example
Input — YAML
# billing service
service: billing-api
image:
repository: registry.example.test/billing
tag: "2026.04.1" # pinnedOutput — YAML
# billing service
service: billing-api
image:
repository: registry.example.test/billing
tag: "2026.04.1" # pinnedGood to know
- Sorting keys changes the file semantically for a reader even though the data is identical — in a config where order is a convention, it can make a diff harder to review rather than easier.
- Quoting style is normalised by the emitter, so a value written in single quotes may come back in double quotes when that is the safer form.
- A document using custom tags is formatted, but the tags are reproduced verbatim and are not interpreted.
Frequently asked questions
Will my comments survive?
Yes. That is the main reason this tool exists rather than telling you to convert to JSON and back. Comments attached to keys, to list items and at the end of a line are all kept.
What happens to a multi-document file?
All of it is formatted. Each document between separators is processed and the separators are put back, so a Kubernetes manifest with five resources comes back with five resources.
Why did my tabs cause an error?
YAML forbids tab characters for indentation because their displayed width is ambiguous. Replace leading tabs with spaces and the file will format.
Does sorting keys reorder my lists?
No. Only mapping keys are sorted. Sequence order is data in YAML, so reordering it would change the document rather than tidy it.
Your data stays on your device
Your data is processed locally in your browser and is not uploaded to our server. This page keeps working after you go offline, because there is nothing to send.
Related tools
- YAML ValidatorDeveloper ToolsValidate a YAML stream, with duplicate keys treated as the error they are.YAMLReport
- YAML to JSONConvertersParse YAML configuration into JSON, with clear errors for indentation mistakes.YAMLJSON
- JSON to YAMLConvertersConvert JSON into readable YAML for Kubernetes, CI pipelines and app configuration.JSONYAML
- YAML to CSVConvertersFlatten a YAML sequence into spreadsheet columns, with nested keys as paths.YAMLCSV
- XML FormatterDeveloper ToolsRe-indent or minify XML, keeping comments and whitespace inside elements.XMLXML