How to Format YAML
YAML Formatting
When to Format YAML
Format YAML from Kubernetes manifests, GitHub Actions workflows, Docker Compose files, and Ansible playbooks. Consistent indentation makes diffs readable and errors easier to spot.
YAML vs JSON
YAML supports comments, multi-line strings, and anchors. It is human-friendly but indentation-sensitive — a single wrong space can break parsing. Always validate after formatting.
Frequently asked questions
Will formatting change my YAML semantics?
Formatting re-parses and re-serializes the document. Comments and custom tags may be lost. Review the output before committing to version control.
What indentation does the formatter use?
Output uses 2-space indentation, the most common YAML convention.