YAML Formatter
Tidy YAML files such as Kubernetes manifests, Docker Compose files and CI pipelines with consistent indentation, without losing comments.
or drop a file here · .yaml, .yml, .txt · up to 20 MB
About the YAML Formatter
YAML relies on indentation to show structure, so a file where some blocks use two spaces and others four is hard to review and easy to break. This formatter rewrites the whole file with one consistent indentation while keeping comments, key order and anchors.
It suits Kubernetes manifests, Docker Compose files, CI pipelines, Ansible playbooks and OpenAPI specifications.
When to use it
- Several people edited a manifest and the indentation drifted.
- You pasted a snippet from documentation and it no longer lines up with the rest of the file.
- You want a uniform style before a code review so the diff shows only real changes.
Worked example
Try an example fills the box with a sample that has a server block indented by four spaces, a users list whose dashes sit at the left margin, extra spaces after “tls:”, and a comment on the first line. Keep 2 spaces and select Format YAML.
In the result, everything under server moves to two spaces, the list items under users are indented by two spaces with their dashes, and “tls: true” loses its extra spaces. Flow lists such as [80, 443] are kept on one line, written with a space inside each bracket. The comment “# Example settings” is still at the top.
What it does not do
- It does not re-wrap long lines or change block text written with | or >.
- It does not sort keys. Order often carries meaning in YAML, for example the steps of a pipeline.
- It does not check that the keys are correct for your program. A manifest can be perfectly formatted and still be rejected by Kubernetes.
Good to know
- Files with several documents separated by — are supported, and the separators are kept.
- Tabs used for indentation are an error in YAML, so such a file must be fixed first. The YAML validator shows where they are.
- To turn the file into JSON, use YAML to JSON.
How to use YAML Formatter
- Paste YAML or open a .yaml or .yml file.
- Choose 2 or 4 spaces.
- Select Format YAML, check the result, then copy or download it.
Privacy: how it works
Everything happens in your browser. Your text is not sent to any server.
Frequently asked questions
Are my comments kept?
Yes. Comments, anchors and aliases, and the order of keys are kept. Only spacing and indentation are made consistent.
Does it support several documents in one file?
Yes. Documents separated by --- are formatted one after another and the separators are kept.
Why did some quotes change?
The formatter may write quotes and flow lists in a standard style, for example {b: 2} becomes { b: 2 }. The values themselves do not change.