YAML formatter and re-indenter
Paste YAML with inconsistent indentation, stray tabs or untidy spacing and get back a normalised document. This is the quick fix for config files — Docker Compose, Kubernetes manifests, GitHub Actions workflows, Ansible playbooks — that have drifted into mixed two- and four-space indents or picked up a tab that breaks the parser.
How it works
The formatter is a dependency-free re-indenter, not a full parser, which keeps it fast and lossless. It works in three steps:
- Expand tabs to spaces — YAML disallows tabs for indentation, so every tab becomes two spaces.
- Detect and normalise depth — it measures the leading-space depth of each line, finds the smallest positive gap between distinct depths as your source step, then snaps every nesting level onto your chosen 2- or 4-space unit.
- Tidy spacing — it collapses runs of spaces after the first
key:colon and after a list-.
Lines inside a | or > block scalar are detected by being more indented than
their key and are copied verbatim, so embedded scripts and text keep their exact
layout. Keys, values and block contents are never changed — only whitespace.
Example
Messy input (note the mixed spacing and over-indented dashes):
name: Gera Tools
tools:
- xml
- yaml
meta:
runs: browser
Formatted with a 2-space indent:
name: Gera Tools
tools:
- xml
- yaml
meta:
runs: browser
| Indent option | Common use |
|---|---|
| 2 spaces | Default for Compose, Kubernetes, CI YAML |
| 4 spaces | Teams preferring wider visual nesting |
Everything runs in your browser as plain JavaScript, so your YAML — and any secrets in it — never leaves your device.