Browser-local code formatter

YAML Formatter

Normalize YAML indentation to two spaces, check the structure, and get the line number when it breaks.

YAML Formatter

Processed in this browser
Paste YAML
Ready to copy

How to use it

A short path from source data to a usable local result.

01

Add YAML

Paste or upload a mapping or a list with consistent indentation.

02

Format or validate

Format rewrites the structure with two-space indentation; Validate only reports whether it parses.

03

Take the result

Copy the YAML or download it as formatted.yaml.

Common questions

Details that matter when moving data between formats.

Are tabs allowed?

No. A tab on any line is reported with its line number before parsing starts, because YAML indentation must use spaces.

Are comments kept?

No. The document is parsed and written back from its data, so comments and blank lines are dropped. Keep the original if comments matter.

What about anchors and aliases?

They are outside the supported subset and are reported as an error rather than silently dropped.

Does it reorder keys?

No. Keys keep the order they had in the source document.

Related tools

Other focused converters that are already available.

When is YAML Formatter useful?

YAML is easy to read and easy to break. A single tab, an indent that is two spaces on one line and three on the next, or a list item that lost its dash is enough to produce a file that looks fine and parses into something else entirely. A formatter normalizes the structure so indentation is consistent and the shape of the document is visible at a glance. This page parses the YAML in the browser, reports the line number when it cannot, and writes the result back with two-space indentation. The document never leaves the tab.

The formatter works from the data rather than from the text. The document is parsed into a structure and then written back, so indentation is uniform by construction and cannot drift between lines. Keys keep the order they had in the source, nested mappings gain two spaces per level, and lists are written with a dash and a space. A tab anywhere in the file is rejected with its line number before parsing begins, because YAML forbids tabs as indentation and a parser would otherwise fail somewhere far away from the real cause.

Two things are lost by design. Comments and blank lines do not survive, because they are not part of the data, so a heavily commented file should be formatted only to check that it parses. Anchors, aliases, and custom tags are outside the supported subset and are reported rather than silently dropped, which means a file that depends on them needs a full YAML library. Validation stops at the first structural error and names the line: inconsistent indentation, a list that is not under a key, a mapping entry without a colon, or an empty list item. Everything runs in the tab, so a manifest or a CI file that carries credentials can be checked and tidied without being sent to a server, and the original file on disk stays untouched until you save the result yourself.