About the YAML Formatter
This YAML Formatter parses your YAML with a full YAML 1.2 parser. It points to the exact line and column of any syntax error, re-indents valid YAML while keeping comments and anchors, and converts YAML to JSON or JSON to YAML for Docker Compose files, Kubernetes manifests and CI pipelines.
How it works
Your input is parsed with the open-source yaml library, which follows the YAML 1.2 specification. Every document in the file (separated by ---) is parsed, and the first error found is reported with its line and column, along with the surrounding lines.
Format mode prints each parsed document back out with consistent indentation, keeping comments, anchors and aliases. YAML → JSON resolves anchors and outputs JSON (an array when there are several documents), and JSON → YAML parses JSON and writes it as block-style YAML.
How to use
- 1
Choose Format YAML, YAML → JSON or JSON → YAML.
- 2
Paste your input or open a file, and pick 2 or 4 space indentation.
- 3
If there's an error, fix the line shown; otherwise read the formatted output.
- 4
Copy or download the result, or click Replace input to keep the formatted YAML.
Worked examples
Reformat four-space YAML
A config indented with four spaces.
Tab indentation
A key indented with a tab character.
YAML forbids tabs for indentation, so the parser stops at that line.
Frequently asked questions
Why is YAML so sensitive to indentation?+
YAML uses indentation instead of brackets or tags to show nesting, so a few extra or missing spaces can change the meaning of a file or make it fail to load.
Can I use tabs in YAML?+
No. The YAML specification does not allow tabs for indentation, and this tool reports any tab used as indentation with its line number.
Does this tool reformat my YAML?+
Yes. Format YAML re-indents every document to 2 or 4 spaces and keeps your comments.
Is four-space YAML valid?+
It isn't. Four-space YAML is valid; the formatter can convert it to two spaces if you choose.
Does "Valid YAML" mean my file will load?+
Yes, as far as syntax goes: the file is parsed with a full YAML parser. It doesn't check the keys against a schema such as Kubernetes or Compose.