Skip to content
Devtoolry

YAML Formatter

Format and normalise YAML online with consistent indentation using Prettier. Clean up Kubernetes, Docker Compose and CI config files in your browser.

Runs in your browser · Nothing uploadedFree · No sign-up

Something not working, or missing a feature? Send feedback

About the YAML Formatter

Inconsistent indentation is the most common cause of broken YAML. The YAML Formatter normalises indentation and spacing with Prettier so configuration files stay readable and valid. Use it to fix YAML indentation in .yml files (YML and YAML are the same format): if the file does not parse, the error shows the line to fix first.

Everything runs in your browser, so your input is never uploaded to a server.

How to use the YAML Formatter

  1. Paste YAML or open a .yml/.yaml file.
  2. Review the formatted output.
  3. Copy or download it.

Example

Normalise a hand-edited Compose file

Input

services:
    web:
        image: "nginx:1.27"
        ports: [ "80:80", "443:443" ]
        environment:
            - TZ=UTC   # server time
    db:
        image: postgres:16

Result

services:
  web:
    image: "nginx:1.27"
    ports: ["80:80", "443:443"]
    environment:
      - TZ=UTC # server time
  db:
    image: postgres:16

Indentation becomes two spaces at every level, flow sequences are spaced consistently and the comment stays on its line. The data itself is unchanged.

Common mistakes

  • Tabs for indentation. YAML does not allow tab characters for indentation. Replace them with spaces; the error message points to the first tab.
  • Unquoted colons in values. A value such as title: Note: read me is ambiguous. Quote it ("Note: read me") so the second colon is part of the string.
  • Formatting a templated file. Helm charts and other templates with {{ }} placeholders are not valid YAML until rendered. Format the rendered output, or the plain values file.

Works well with the YAML Formatter

Frequently asked questions

Are comments preserved?

Yes. Comments stay attached to the lines they describe.

Can it convert YAML to JSON?

Use the YAML to JSON converter for that; this tool keeps the format as YAML.

Does it change quoting?

Prettier keeps your values but may switch between single and double quotes where both mean the same string. Values are never unquoted if that would change their type.

Are multi-document files supported?

Yes. Documents separated by --- are each formatted and kept in order.

Guides and tutorials