DevTools Hub

Search tools

Search for a developer tool

Docker

Docker Compose Formatter

Clean up inconsistent indentation in a docker-compose.yml, comments preserved.

Formatted

What this does

Paste a docker-compose.yml with inconsistent indentation — common after merging edits from different editors, or hand-patching a file someone else wrote — and get it back with consistent 2- or 4-space indentation throughout. Comments are preserved, both standalone and inline, and long values (a shell command in a RUN-style string, a lengthy image reference) are kept on a single line rather than folded across multiple lines.

This only touches whitespace and formatting — key order, values, and structure are left exactly as written. It won't reorder services or add missing sections; for checking whether the file is actually correct (undefined service references, bad ports, undeclared volumes), use the Docker Compose Validator.

FAQ

Why does a flow-style list get spaces added inside the brackets?

A list written inline as ["80:80", "443:443"] is reformatted to [ "80:80", "443:443" ] — this is standard YAML flow-style spacing, not a content change. If you'd rather have one item per line, write it as a block list (each item on its own - line) before formatting.

Does it validate the file?

It checks that the YAML itself parses — unbalanced structure, duplicate keys, and similar syntax problems are reported instead of silently formatting broken input. It doesn't check Compose-specific correctness (missing images, bad ports, undefined volume references); that's what the Docker Compose Validator is for.

Related tools