Skip to content

YAML Formatter

Normalise YAML indentation, quoting and key order in one pass.

Comments are not preserved — they are not part of the parsed document, so re-emitting cannot keep them.

Quick Tool Overview

The YAML Formatter parses a file and writes it back with one indentation width and one quoting rule, quoting any string that would otherwise change type when read — the source of most YAML surprises.

What it does
Normalises YAML indentation, quoting and key order
You give it
Any YAML file
You get back
Consistently formatted YAML
Best for
Compose files, CI configs and Kubernetes manifests
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the YAML Formatter

YAML is whitespace-significant, which makes a hand-edited file drift: two spaces here, four there, some values quoted and some not. The formatter parses the document and writes it back with one indentation width, one quoting rule and, optionally, sorted keys.

The quoting is the part that prevents bugs. YAML reads unquoted no, off, yes and on as booleans, and a value such as 007 as the number 7 — so the formatter quotes any string that would otherwise change type on the next read. Tabs, which YAML forbids for indentation entirely, are converted to spaces. Comments are not preserved, because they have no place in the parsed document.

Key features of the YAML Formatter

Type-safe quoting

Strings such as yes, off, null and 007 are quoted, because unquoted they would come back as a boolean, a null or a number.

Tabs converted

YAML forbids tabs for indentation entirely. Any that crept in are converted to spaces rather than left to break the file.

One indentation width

A hand-edited file that drifted between two and four spaces comes back consistent throughout.

Optional key sorting

Sort keys at every level to make two versions of a manifest comparable by eye or by diff.

Multi-document files

Documents separated by --- are all read, so a Kubernetes manifest bundle is handled as one input.

How to use the YAML Formatter

  1. 1

    Paste your YAML

    A Docker Compose file, a CI config, a Kubernetes manifest or any config file.

  2. 2

    Set the indentation

    Two spaces is the near-universal convention; four is also offered.

  3. 3

    Choose the quoting

    Automatic quotes only what needs it; always-quote is safest for values passed to a shell.

  4. 4

    Copy the result

    The tidied document is ready to commit.

Frequently asked questions

The specification forbids them for indentation, because a tab has no fixed width and the structure depends on exact columns. The formatter converts them to spaces.

Reviews of the YAML Formatter

What people who use the YAML Formatter think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the YAML Formatter. It takes half a minute and no account.

Write the first review

More developer tools