YAML Beautifier
Pretty-print YAML with consistent indentation.
YAML Beautifier – YAML Pretty Print Online
YAML depends on indentation, so inconsistent spacing is more than a cosmetic problem: it makes files hard to read and easy to break. The YAML beautifier reformats YAML with consistent indentation and spacing while keeping comments, anchors, and multi-line strings intact.
What it does
- Re-indents mappings and sequences with 2 or 4 spaces per level.
- Normalizes spacing after colons and dashes (
key: value→key: value). - Formats flow collections like
[ "80:80", "443:443" ]and{ replicas: 2 }with consistent spacing. - Keeps comments, document separators (
---), anchors and aliases, tags, and block scalars (|and>). - Optionally prefers single quotes for strings that need quoting.
Works with every YAML file
Docker Compose files, Kubernetes manifests, GitHub Actions workflows, OpenAPI specifications, Ansible playbooks, Helm values, and application configs all use standard YAML 1.2, which this beautifier supports. Multi-document files with several --- sections are formatted document by document.
Errors with line numbers
If the YAML is invalid — a tab used for indentation, a missing colon, or a mapping value where a list item was expected — you get an error with the line and column. Fix it and the formatted result appears immediately.
Beautify without changing data
Formatting never changes the parsed data: keys, values, and types stay exactly as they were. The formatter does not reorder keys or convert between flow and block style, so your intentional choices are kept.
Related YAML tools
Validate the structure and see statistics with the YAML Validator, convert YAML with the YAML to JSON converter, or explore it as a tree in the YAML Parser. For JSON configs, use the JSON Beautifier.
Frequently Asked Questions
Are comments preserved?
Yes. Comments, blank-line structure between sections, anchors, aliases, and tags are kept.
Why can't I choose tabs?
The YAML specification forbids tabs for indentation, so only spaces are offered.
Does it convert flow style to block style?
No. Flow collections like [a, b] stay flow collections; only their spacing is normalized. The formatter respects the style you chose.