Skip to main content

Ansible Playbook YAML Formatter

Clean up messy Ansible playbook, role, or task-list YAML by normalizing indentation to a consistent 2- or 4-space step and tidying list-item dashes. Runs entirely in your browser — nothing is uploaded.

Input

Drop a file or browse
One file · text
Or

Output

Formatted YAML
 
Was this helpful?

Guides

Messy Ansible YAML is one of the most common friction points in DevOps workflows — playbooks get copy-pasted between roles, edited by different team members with different editor settings, or pasted from Slack and ticket trackers, and end up with a mix of 2-space, 3-space, and 4-space indentation in the same file. Since YAML's structure is its whitespace, inconsistent indentation isn't just ugly — it can silently change what a task belongs to.

This tool re-indents Ansible playbook, role, and task-list YAML to a consistent indentation step (2 or 4 spaces), so the visual structure matches what the document actually means. It also tidies up list-item dashes, collapsing - name: foo or -name: foo down to the conventional - name: foo.

How to use it

  1. Paste your playbook.yml, a role's tasks/main.yml, or any task list into the input box — or upload a .yml/.yaml file directly.
  2. Pick 2 spaces or 4 spaces as your indent size (2 is the Ansible community convention).
  3. The formatted YAML appears instantly in the output panel. Copy it or download it as playbook.yml.

The tool updates as you type, so you can paste rough, copy-pasted YAML and watch it snap into a clean, consistent shape.

What it does — and what it doesn't

This formatter works line-by-line: it tracks how deeply each line was originally indented relative to the lines around it, then re-emits every line at a proportional, uniform indent step. That's enough to fix the vast majority of real-world messy YAML — inconsistent spacing, tabs mixed with spaces, and ragged list markers.

What it deliberately does not do is parse YAML into a structured document. It doesn't reorder Ansible task keys (name → module → whenregister, etc.), validate playbook structure (missing hosts:, tasks without a module), or flag ansible-lint-style issues like short module names that should be fully-qualified collection names. Those all require a real YAML parser and Ansible-aware schema knowledge that this lightweight, dependency-free formatter doesn't attempt. If your YAML uses flow-style collections ({ key: value }, [a, b, c]) or multi-line block scalars (|, >), those values pass through as-is rather than being restructured — only the line-level indentation and list markers are normalized.

For most everyday "my playbook is a mess, please clean up the whitespace" tasks, that's exactly what's needed. For deep linting, run ansible-lint itself.

Is my YAML uploaded anywhere?

No. Formatting happens entirely in your browser — the YAML you paste or upload never leaves your device or touches our servers.

Will this validate my playbook is correct?

No — it only normalizes indentation and list-marker spacing. It won't catch missing required keys, invalid module names, or logic errors. Use ansible-playbook --syntax-check or ansible-lint for real validation.

Does it work on non-Ansible YAML too?

Yes. Although it's framed around Ansible playbooks, the underlying operation is a general-purpose YAML re-indenter — it works fine on Kubernetes manifests, GitHub Actions workflows, or any other YAML file that just needs its indentation cleaned up.

What happens if I paste invalid or non-YAML text?

The formatter never errors out. Since it works on lines and indentation rather than parsing a document, it will simply re-indent whatever text you give it as best it can, rather than showing a parse-error message.

yamlansibleplaybookformatterdevopsindentation

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.