YAML formatter
Re-emit YAML in canonical block style with consistent indentation and quoting. Useful for files that several people and several tools have edited.
Conversion happens in this browser tab. Nothing is uploaded, logged, or stored.
Normalising YAML
The formatter parses your YAML and re-emits it in canonical block style: consistent indentation, consistent quoting, flow collections expanded into block form. Use it when a file has been edited by several people and several tools and no longer has one coherent style.
One thing to know before you paste: comments are not preserved. The
formatter parses to a data structure and writes it back out, and comments live outside
that structure. If your file is documented — and a good values.yaml is —
format a copy and re-apply the comments, or use a comment-preserving tool such as
ruamel.yaml or prettier.
Before and after
name: checkout-api
resources: {cpu: 500m, memory: 512Mi}
env:
- name: LOG_LEVEL
value: 'info'
ports: [8080, 9090]name: checkout-api
resources:
cpu: 500m
memory: 512Mi
env:
- name: LOG_LEVEL
value: info
ports:
- 8080
- 9090Flow style — the {} and [] forms — is valid YAML and stays
valid. It is worth keeping for genuinely short values such as
ports: [80, 443]. Block style wins as soon as a collection has more than
two or three entries, or when reviewers need to comment on individual lines.
Conventions worth adopting
- Two spaces per level. Four is legal but pushes deeply nested manifests off the right edge of a review pane.
- Indent list items under their parent key. Both forms are valid, but the indented form is what Kubernetes, Ansible, and GitHub Actions examples use.
- Never use tabs. They are forbidden in indentation and will fail to parse, as the indentation rules explain.
- Use block scalars for anything with newlines in it, rather than escaping them into one long quoted line.
- Quote anything ambiguous: version numbers, values that look like booleans, strings with a leading zero, anything containing a colon.
- One document per file where you can. Multi-document files with
---separators are harder to tool around. - End the file with a single newline.
Formatting in your editor and CI
# Prettier — preserves comments, good for repositories
npx prettier --write '**/*.{yml,yaml}'
# yq — normalises structure, drops comments
yq -P -i '.' config.yaml
# yamllint — reports style problems rather than fixing them
yamllint -d '{extends: default, rules: {line-length: {max: 120}}}' .
For a repository, Prettier is usually the right choice because it keeps comments. Use
yq for one-off normalisation of generated files.
Formatting happens locally
Files that need reformatting are files several people have edited, which in practice means Helm values, environment overlays, and deployment configs — the documents that hold connection strings and know every hostname in an estate.
The formatter never sees a network. It parses and re-emits your document inside this browser tab, and keeps no copy. If you would not paste a file into an unfamiliar web form, you can still paste it here, because there is no form and no endpoint.