DataToolsLab
YAML Tools

YAML Formatter

Pretty-print and indent YAML with comment preservation.

Loading tool…

What is YAML Formatter?

The YAML Formatter takes compact or inconsistently indented YAML and reformats it with consistent 2- or 4-space indentation. It preserves comments — a key differentiator from many online formatters.

How it works

We use js-yaml to parse the YAML into its data structure, then re-serialize with consistent formatting. All processing happens locally in your browser.

  1. Paste YAML. Paste or drop a .yaml file.
  2. Choose options. Select indent size and whether to sort keys alphabetically.
  3. Copy or download. Copy to clipboard or download as formatted.yaml.

Examples

Kubernetes manifest

Clean up a messy Deployment YAML with consistent indentation.

Common mistakes

Tabs for indentation

YAML forbids tabs. Use spaces or let the formatter fix it.

Alternatives

CLI tools like yq

Command-line YAML processors need local installation.

Frequently asked questions

Are comments preserved?

Yes — js-yaml preserves comments during formatting.

Is my config uploaded?

No. All YAML processing happens in your browser.

Online