Ansible Playbook YAML Formatter
Guide
Ansible Playbook YAML Formatter
Paste any Ansible playbook or task file and get back consistently formatted YAML with task keys in the canonical order (name → module → args → loop → when → register → notify). The tool detects whether you pasted a playbook or a task list, validates the structure, and surfaces ansible-lint style hints — FQCN module names, missing changed_when, command-instead-of-module, and legacy yes/no truthy values — so your playbooks pass review on the first try.
How to Use
- Paste your Ansible YAML into the input box — a full
playbook.yml, a role’stasks/main.yml, or any task list. - Leave Reorder Task Keys on to apply the conventional ansible-lint key ordering, or turn it off to keep your original order.
- Keep Validate Ansible Structure on for play/task shape checks (missing
hosts, tasks without a module, malformedblock). - Toggle Show ansible-lint Style Hints for best-practice nudges like FQCN module names, missing names, and idempotency warnings.
- Copy the formatted output or download it as
playbook.yml.
Features
- Conventional task key order –
namefirst, then the module, thenargs,loop,when,register,notify— the order ansible-lint expects. - Playbook vs task-list detection – Automatically applies play-level ordering (
hosts,vars,pre_tasks,tasks,post_tasks,handlers) when a playbook is detected. - Block / rescue / always aware – Reorders nested block-style tasks without breaking their semantics.
- Structural validation – Flags plays missing
hosts, tasks without a module, malformed lists, and unknown play-level keys. - FQCN hints – Suggests
ansible.builtin.aptover bareapt, matchingfqcn[action-core]. - Idempotency hints – Warns when
command/shellruns withoutchanged_when,creates, orremoves. - command-instead-of-module detection – Spots shelled-out package installs, systemctl calls, git clones, and pip installs that have first-class modules.
- Legacy truthy detection – Flags
yes/no/on/offvalues that should betrue/false(yaml[truthy]). - Deprecated loop warnings – Highlights
with_items,with_dict, and friends so you can migrate toloop:. - Runs entirely in your browser – Nothing is uploaded; your inventory and secrets stay local.
FAQ
-
Why does ansible-lint care about task key order?
Consistent key order makes playbooks scannable: the task's intent (
name) reads first, then the module that performs the action, then its arguments, then any control flow (loop,when,register,notify). When everyone on a team follows the same order, diffs stay focused on real changes instead of cosmetic shuffling, and reviewers can pattern-match on tasks at a glance. -
What is FQCN and why use it for modules?
FQCN stands for Fully Qualified Collection Name — the full
namespace.collection.modulepath, likeansible.builtin.aptinstead of justapt. Since Ansible 2.10 split modules into collections, bare names can resolve ambiguously when multiple collections ship a module with the same short name. FQCNs make resolution explicit, document the source of every module, and protect playbooks from collection ordering changes. -
When should I use loop: instead of with_items:?
The
with_*lookup-based loops were the original way to iterate, but they couple iteration with lookup plugins, which limits composability. Theloop:keyword (introduced in 2.5) takes any list directly and pairs cleanly withloop_controlfor indexing, labels, and pauses. For simple list iteration, always preferloop:; only fall back towith_*for the few patterns that don't yet have a cleanloopequivalent. -
Why is YAML 'yes' considered legacy in Ansible?
YAML 1.1 treated
yes,no,on,off,true, andfalseas booleans. YAML 1.2 narrowed booleans to justtrue/false. To stay forward-compatible and unambiguous — especially when YAML values are later consumed by tools outside Ansible — ansible-lint'syaml[truthy]rule recommends sticking totrueandfalse. Using the strict booleans also avoids surprises when a literal stringyesis needed as data. -
Why declare changed_when on command/shell tasks?
Ansible determines whether a task changed the system by inspecting module return data. The
command,shell, andrawmodules can't know that on their own — they treat any successful execution as a change, which makes idempotency checks lie. Declaringchanged_when(or usingcreates/removes) lets you encode the real change condition: a specific exit code, output pattern, or file marker. Idempotent playbooks become quieter and more diff-able as a result.
Install Our Extensions
Add IO tools to your favorite browser for instant access and faster searching
恵 Scoreboard Has Arrived!
Scoreboard is a fun way to keep track of your games, all data is stored in your browser. More features are coming soon!
Must-Try Tools
View All New Arrivals
View AllUpdate: Our latest tool was added on Jun 8, 2026
