YAML Formatter

Normalise YAML into consistent block style with the indent you choose, and catch indentation mistakes before a deploy does.

YAML
Formatted YAML
Runs locally in your browser

About the YAML Formatter

YAML is whitespace-sensitive, and files edited by several people drift: two-space and four-space blocks side by side, inline flow mappings mixed with block style, keys in random order. This formatter parses the document, so every indentation error is caught, then re-emits it in a single consistent style: block mappings and sequences, your chosen indent, and quotes only where the value would otherwise change type.

Multi-document files separated by --- are supported and come back as separate documents. Anchors and aliases are resolved, which means repeated content is expanded; that is safer for most consumers, but keep the original if you rely on anchors to reduce size. Comments are not preserved, because the YAML data model has no place for them; if comments matter, format only the block you are changing.

Long strings can be wrapped at 80 or 120 columns or left as single lines. Sorting keys alphabetically is optional and useful for lock-style files that are diffed in version control. To convert instead of format, see YAML to JSON.

How to use

  1. Paste YAML on the left or upload a .yaml / .yml file.
  2. Choose the indent and whether keys should be sorted.
  3. Fix any reported line, then copy or download the result.

Common questions

Why did my comments disappear?
The formatter rebuilds the file from the parsed data, and YAML comments are not part of the data. Reapply them after formatting, or format only the sections you changed.
Are anchors and aliases kept?
They are resolved into the repeated content. Consumers see the same data; the file just gets longer.
Does it change the type of values?
No. Strings that look like numbers or booleans are quoted in the output so they stay strings.
Which YAML version does it follow?
YAML 1.2 core schema. The output is also valid for 1.1 parsers.