YAML Formatter
Format YAML in your browser. Re-indent, sort keys, and prettify or compact YAML configuration files. Powered by js-yaml 4.x with full YAML 1.2 conformance.
Messy in, clean out
Same data, structured for human eyes. Formatting expands compact YAML into a line-per-key, properly indented document.
name: hcodx items: [1, 2, 3]
name: hcodx items: - 1 - 2 - 3
What you'll use this for
Anywhere unreadable YAML shows up — Kubernetes manifests, CI pipelines, Ansible playbooks, compose files.
Kubernetes manifests
Reformat manifests after editing — consistent indent, no surprises for kubectl.
GitHub Actions
Tidy a .github/workflows/*.yml after merging changes.
Ansible / Compose
Format playbooks and compose files to a single shared style.
OpenAPI specs
Pretty-print a YAML OpenAPI spec for diffs and review.
How to format YAML
Paste your YAML
Drop it into the left editor. Compact flow-style or block-style YAML both work.
Pick indent
2 spaces by default. Switch to 4 spaces or tab to match your project style.
Click Format
Or leave auto-format on for live updates. Runs locally with jsyaml.load + jsyaml.dump.
Copy or download
Copy to clipboard, save as .yaml, or flip the Mode to Minify to compact back.
Frequently asked questions
Yes. No signup, no limits, no ads.
Yes — syntax errors are highlighted with line numbers reported by js-yaml. Use the YAML Validator for richer schema and structural checks.
Yes — runs in your browser. Nothing is uploaded.
YAML 1.2 via js-yaml 4.x.
Yes by default. Toggle Sort keys to alphabetize recursively.
About this formatter
YAML formatting is a one-pass operation: jsyaml.load parses the input into a JS value, then jsyaml.dump serializes it again with explicit indentation. The result is canonical block-style YAML conforming to the YAML 1.2 spec — same structure regardless of whether the input was flow-style, compact, or hand-typed.
What it does
- Indents at 2 spaces (default), 4 spaces, or tab.
- Block style by default — one key per line in maps, one item per line in sequences.
- Optional sort alphabetizes keys recursively (toggle).
- Minify mode flips to flow-style output for compact single-line YAML.
- YAML 1.2 via js-yaml 4.x — broad tag, scalar, and Unicode support.
What it doesn't do
- Round-trip comments perfectly. js-yaml does not preserve inline comments in all edge cases. Block comments at the top usually survive; expect some loss in complex docs.
- Preserve anchors & aliases by default. They're inlined (
noRefs: true) for readability. Toggle source if you need to retain&name/*namereferences. - Schema validation. Syntactic only — use the YAML validator for structural checks.