Skip to content

YAML Formatter & Beautifier

Re-indent and normalise a YAML file while keeping comments, anchors and multi-document structure.

Processed locally in your browser

Options
0 chars · 0 lines
The result will appear here.

What is YAML Formatter & Beautifier?

YAML is the configuration language of Kubernetes, Docker Compose, GitHub Actions, OpenAPI and countless other tools. It is indentation-sensitive, so small inconsistencies (mixed indent widths, odd spacing in flow lists) make files hard to read and hard to review.

This formatter parses your YAML with the yaml library (YAML 1.2, core schema) and prints it again with 2 or 4 spaces, a line width you choose, and optional alphabetical sorting of mapping keys. Comments, anchors (&a), aliases (*a), merge keys (<<) and multiple documents separated by --- are preserved. Nothing in the document is ever executed.

How does it work?

  1. Paste your YAML or open a .yaml / .yml file.
  2. Choose 2 or 4 spaces, the line width (0 disables wrapping) and whether to sort keys.
  3. If the YAML is invalid, read the error: it gives the line and column.
  4. Copy the formatted result or download formatted.yaml.

Common use cases

  • Normalising Kubernetes manifests or Helm values before a commit.
  • Cleaning a docker-compose.yml or CI workflow with inconsistent indentation.
  • Sorting keys of a configuration so that two files diff cleanly.
  • Converting flow-style snippets ({a: 1, b: [2, 3]}) to readable block style with the same data.

Examples

Try this input in the tool above:

Input
# service config
service:
      name:   api
      ports: [80,   443]
      env:
            - {name: MODE,   value: prod}
            - {name: DEBUG, value: "false"}
limits: &limits
   cpu:  "500m"
   memory: 256Mi
worker:
   <<: *limits
   replicas: 3
Output
# service config
service:
  name: api
  ports: [ 80, 443 ]
  env:
    - { name: MODE, value: prod }
    - { name: DEBUG, value: "false" }
limits: &limits
  cpu: "500m"
  memory: 256Mi
worker:
  <<: *limits
  replicas: 3

Privacy

YAML Formatter & Beautifier runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.

Limitations

Formatting may change quote styles or the spelling of some scalars (for example 0x1F becomes 0x1f), and long plain text can be folded at the chosen line width. Sorting keys reorders mappings and can affect tools that depend on key order.

Frequently asked questions

Are comments preserved?

Yes. Comments stay attached to the entries they belong to, even when keys are sorted.

Which YAML version is used?

YAML 1.2 with the core schema, so values like yes, no or on are plain strings, not booleans. Only true and false are booleans.

Is it safe to paste untrusted YAML?

Yes. Only data is parsed, custom tags are never executed, and alias expansion is limited to stop “billion laughs” documents.

More tools in JSON & Data →