Ad
DevToolXDevToolX

YAML Formatter

Format, validate and beautify YAML data

About YAML Formatter

YAML Formatter parses your input with a YAML 1.2 safe-loader and re-serializes it with normalized indentation, catching errors like duplicate keys, tabs-instead-of-spaces, or type ambiguities that break Kubernetes, GitHub Actions, and similar toolchains. The spec is permissive in what it accepts and strict in a few surprising ways — this tool makes those edge cases visible before they reach a CI runner or a cluster.

Common Use Cases

Validate Kubernetes manifests
Kubernetes rejects YAML with indentation errors or duplicate keys silently in some versions; format and validate before running kubectl apply.
Debug GitHub Actions workflows
Workflow YAML is parsed by GitHub's own engine, which has its own quirks around multiline strings and anchors — format to normalize before pushing.
Edit docker-compose files
Docker Compose is sensitive to indentation and type coercion; the formatter surfaces a misplaced key or unexpected type before docker compose up fails mid-way.
Check Ruby and Python config files
Rails database.yml, Ansible playbooks, and Python project configs all use YAML — validate to catch merge key errors and implicit type conversions before deploy.

Frequently Asked Questions

Why must YAML use spaces and not tabs?

YAML 1.2 forbids tab characters for indentation. The rationale is that tabs have ambiguous width — different editors and terminals render them differently, making indentation-based parsing unreliable. Any tab in an indentation position is a hard parse error. Configure your editor to insert spaces when you press Tab in YAML files.

What is the YAML 1.1 Norway problem?

In YAML 1.1, bare words like yes, no, on, off, true, false were all parsed as booleans. The ISO country code NO (Norway) would therefore resolve to false when used unquoted as a value. YAML 1.2 restricted boolean literals to just true and false, but many parsers — including PyYAML's default loader — still implement 1.1 rules. Quote ambiguous values like no, yes, and country codes to be safe.

What are YAML anchors and aliases?

An anchor (&name) marks a node for reuse; an alias (*name) pastes a reference to that node. They are useful in docker-compose and CI configs to avoid repeating the same environment block. Merge keys (<<: *anchor) let you overlay a map on top of an existing one. The formatter preserves anchors and aliases without flattening them.

When should I quote a string in YAML?

Quote values that look like other types: "3.14" stays a string, 3.14 becomes a float; "true" stays a string, true becomes a boolean; "null" stays a string, null becomes nil. Also quote strings containing :, #, {, }, [, ], or leading/trailing spaces to prevent the parser from misreading them as structure.

YAML vs JSON — when should I use each?

YAML is easier for humans to write and read — no braces, supports comments, multiline strings. JSON is better for machine-to-machine exchange — unambiguous types, no surprise coercions, universally supported. For config files humans maintain, YAML; for API payloads, JSON.

Related Tools