YAML Formatter & Beautifier
Re-indent and normalise a YAML file while keeping comments, anchors and multi-document structure.
Processed locally in your browser/ Your data stays in your browser.
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?
- Paste your YAML or open a .yaml / .yml file.
- Choose 2 or 4 spaces, the line width (0 disables wrapping) and whether to sort keys.
- If the YAML is invalid, read the error: it gives the line and column.
- 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:
# 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
# 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.
Related tools
YAML Validator
Check that a YAML file is valid and find the exact place where it breaks.
JSON & Data
YAML to JSON Converter
Turn YAML into strict JSON, resolving anchors, aliases and merge keys along the way.
JSON & Data
JSON to YAML Converter
Turn JSON into readable block-style YAML, with strings quoted only when necessary.
JSON & Data
JSON Formatter & Beautifier
Turn a minified or messy JSON document into readable, consistently indented text, with a precise error message if the JSON is invalid.
JSON & Data
JSON Key Sorter
Reorder the keys of every JSON object alphabetically to get a stable, canonical document.
JSON & Data
XML Formatter & Beautifier
Turn compressed or messy XML into a cleanly indented document that is easy to read and review.
JSON & Data
JSON Validator
Check whether a piece of text is valid JSON and locate the exact character where it goes wrong.
JSON & Data