Skip to content

YAML Formatter

Re-indent YAML consistently while keeping your comments, anchors and key order.

YAML input

Tab inserts indentation. Press Escape, then Tab, to move focus out of the editor.

Formatted YAML

How to format YAML

  1. Paste YAML on the left, or open or drop a .yaml or .yml file.
  2. The re-indented YAML appears on the right. Choose 2 or 4 spaces and the list style.
  3. Copy the result or download it as a .yaml file.

Consistent indentation, comments intact

In YAML, indentation is the structure, so mixed indentation from copy-pasting snippets is both hard to read and a common source of bugs. The YAML formatter parses the file and writes it back with one consistent indentation — while keeping your comments, anchors, aliases, quotes and key order.

Before
server:
      port: 80   # http
      hosts:
      - a.example.com
After (2 spaces, indented lists)
server:
  port: 80 # http
  hosts:
    - a.example.com

Use cases

  • Tidy Kubernetes manifests, Helm values and Docker Compose files.
  • Normalise GitHub Actions, GitLab CI and other pipeline files before a review.
  • Clean up OpenAPI specs and application config files.

Related tools

If formatting reports an error, the YAML validator explains it. To use the data elsewhere, convert with YAML to JSON, or go the other way with JSON to YAML. For JSON files, use the JSON formatter.

Frequently asked questions

Are YAML comments kept when formatting?
Yes. Comments, anchors, aliases and the order of keys are preserved; only indentation and spacing are normalised.
Should list items be indented?
Both styles are valid YAML. Indented lists (the default here) are common in Kubernetes and GitHub Actions files; unindented lists are common in Ansible. Pick the style your project uses.
Why does formatting fail?
The YAML has a syntax error — often inconsistent indentation or a tab character. The error shows the line; the YAML validator explains it in more detail.
Does it support multiple documents?
Yes. Documents separated by --- are formatted one after another and kept in the same file.