Skip to main content
Workbench

YAML Formatter

Tidy up YAML without losing what matters. Comments, anchors, aliases, tags, block scalars, and key order are preserved. Keys are never sorted unless you explicitly ask, and aliases are never silently expanded.

Inputyaml
Loading editor…
YAML○ Not checked0 lines0 chars0 B

How to use the yaml formatter

  1. Paste or upload YAML (.yaml or .yml).
  2. Choose indentation and YAML version (1.2 by default).
  3. Press Format. Comments, anchors, aliases, tags, and key order are preserved.
  4. Keys are never sorted and aliases are never expanded unless you explicitly ask.

Example: Tidying YAML without losing comments

Input
# db config
host: localhost
port:    5432
Output
# db config
host: localhost
port: 5432

Comments and structure are preserved; only inconsistent spacing is normalized.

Frequently asked questions

Will formatting remove my comments?
No. The formatter preserves comments, anchors, aliases, tags, block scalars, and key order. It never performs destructive changes silently.
Does it expand anchors and aliases?
No. Anchors (&name) and aliases (*name) are kept as-is. They are only expanded if you convert to JSON, and you are warned when that happens.
Can I sort keys?
Only if you opt in. Sorting is off by default and, when enabled, the tool notes that it changed the original order.