YAML Formatter
Format and validate YAML documents
About YAML Formatter
Paste a YAML document and choose Format to rewrite it with consistent 2-space indentation and quoting, or Validate to check the syntax without changing anything; a Valid or Invalid badge shows the result. Parsing happens entirely in your browser, which makes it suitable for Kubernetes manifests, CI workflows or config files with internal hostnames.
Category: Text.
Frequently asked questions
What does formatting YAML do?
▾
The document is parsed with js-yaml and written back out with 2-space indentation, block-style lists and mappings, and quotes only where needed; key order is kept and long strings are folded at 120 characters. The data stays the same, but the text is regenerated from scratch rather than adjusted in place.
Are comments and anchors preserved?
▾
No. Comments are removed, merge keys (<<) are expanded into regular keys and anchors are renamed to generic names such as &ref_0. Unquoted dates also come back as full ISO timestamps, so keep your original file if those details matter.
How are YAML errors reported?
▾
Both Validate and Format show the js-yaml error message with the line and column, for example bad indentation of a mapping entry (3:2) or duplicated mapping key (2:1). Input with several documents separated by --- is rejected, so check them one at a time.
What is the recommended indentation for YAML?
▾
2 spaces is the most common convention (used by Kubernetes, Docker Compose, GitHub Actions), and it's what this formatter outputs. YAML doesn't allow tabs for indentation, so always indent with spaces.