How it works
The YAML Formatter validates, formats, and normalizes YAML files — enforcing consistent indentation (2-space or 4-space), sorting keys, and catching syntax errors. Use it before committing YAML to a repository, debugging malformed YAML config files, or normalizing YAML exported from different tools.
YAML is used pervasively in configuration: GitHub Actions, Kubernetes manifests, Docker Compose, Ansible playbooks, Helm charts, Jekyll front matter, and hundreds of other tools use YAML config files. Malformed YAML (wrong indentation, tab characters instead of spaces, missing colons, incorrect quote handling) causes silent failures or confusing parse errors. This formatter catches all of these before deployment.
How to use it: paste your YAML into the input field or upload a .yaml/.yml file. Syntax errors are highlighted inline with line numbers and error descriptions. Valid YAML is reformatted with consistent indentation. Click Copy Output or Download.
Common YAML errors caught: using tabs instead of spaces (YAML requires spaces), inconsistent indentation levels, duplicate keys (same key twice in the same mapping), special characters in values that require quoting but aren't quoted, and incorrect multi-line string syntax (| vs. >).
Key sorting: toggle Sort Keys to produce alphabetically sorted YAML — useful when comparing two config files where key order is the only difference.
Privacy: YAML parsing and formatting run in the browser.
Frequently Asked Questions
- The YAML 1.1 and 1.2 specifications explicitly prohibit tab characters for indentation. This is because tab display width varies by editor configuration (2, 4, or 8 spaces), making tab-indented YAML ambiguous. The specification requires spaces only. This tool detects tabs, reports the line numbers, and converts them to spaces.
- The | (literal block scalar) preserves line breaks — each newline in the source becomes a newline in the parsed value. The > (folded block scalar) converts line breaks to spaces — the content is treated as a single paragraph. Use | for code blocks and formatted text, use > for long prose that should flow as one line.
- Duplicate keys (same key appearing twice in the same mapping) are technically invalid in YAML 1.2 (it's a spec violation). Most parsers accept them but use the last occurrence, silently discarding earlier values. This tool flags duplicate keys as warnings. Review and deduplicate them.
- Different YAML parsers have different strictness levels. Some parsers accept non-spec-compliant YAML (unquoted special characters, tabs, etc.). This formatter validates against the YAML 1.2 specification strictly. Fixing the flagged issues produces YAML compatible with all compliant parsers.