YAML Formatter
Paste any YAML — Kubernetes configs, GitHub Actions workflows, Docker Compose files — and get back clean, consistently indented output.
What is a YAML formatter?
A YAML formatter parses your YAML document and re-serialises it with consistent indentation and spacing. It also validates the input — if the YAML is malformed, you get a precise error pointing to the problem line instead of the silent failures that often occur when copying YAML between tools or editors.
YAML vs JSON — key differences
YAML (YAML Ain't Markup Language) is a superset of JSON designed to be more readable for humans. The main differences developers encounter daily:
- Indentation-sensitive: In YAML, indentation defines structure rather than curly braces and brackets. A wrong indent silently changes meaning or causes a parse error.
- No quotes required: String values do not need quotes in most cases, but some strings must be quoted to avoid type coercion (see the Norway problem below).
- Comments allowed: YAML supports
#comments; JSON does not. - Multiple documents: A single YAML file can contain multiple documents separated by
---. - Anchors and aliases: YAML lets you define a block once with
&anchorand reference it elsewhere with*alias, eliminating repetition in complex configs.
Worth knowing if you use anchors: this formatter's underlying serializer is explicitly configured with aliases disabled, so reformatting expands every *alias reference into a full duplicate of the anchored content. The data is equivalent, but the file gets longer and the anchor/alias relationship doesn't survive a round-trip through this tool.
Common YAML gotchas
YAML's implicit type system converts unquoted values automatically, which causes surprising bugs:
- The Norway problem: The unquoted value
NOis parsed as booleanfalsein YAML 1.1 (used by many tools). Country codes likeno,on,off,yesshould always be quoted as strings. - Octal numbers:
0755is parsed as the octal number 493, not the string "0755". Relevant for Unix permission values. - Floating point:
1.0becomes a float, not a string. Use quotes if you need string "1.0". - Multiline strings: Use
|(literal block, preserves newlines) or>(folded block, folds newlines into spaces) for multi-line values. The choice affects how newlines appear in the parsed value.
YAML 1.1 vs YAML 1.2
Many tools (including PyYAML and older Kubernetes clients) use YAML 1.1 which has the boolean coercion behaviour described above. YAML 1.2 (2009) tightened the spec — only true and false are booleans. When writing configs for modern tools, use YAML 1.2-style values: quote any string that looks like a boolean, use true/false explicitly, and avoid ambiguous number formats.
How to use this tool
- Paste your YAML into the input editor.
- Click Format.
- Review the clean, consistently indented output on the right.
- If the YAML is invalid, the error message identifies the problem line.
- Copy the formatted YAML and use it in your project.
YAML input
name: devtoolshub version: 1.0.0 features: - yaml-formatter - csv-json environment: production: true debug: false
Formatted output
YAML result