{ }jsonkit
Format
Validate
Convert
Query
Generate

YAML formatter

Normalize layout and scalar styles and keep your comments.
Indent
Strings
Collections
Width
80 B · paste or drop a file
1 2 3 4
✓ complete80 B → 82 B0.0 ms

About YAML Formatter

The YAML formatter rewrites valid YAML 1.2 with a consistent layout. It keeps comments, anchors, aliases and multi-document boundaries wherever the YAML syntax tree can hold them.

How it works

Syntax tree formatting

The formatter parses the source into YAML nodes and writes those nodes back out. Comments stay attached to their nodes. A YAML to JSON round trip would drop them.

Style options

Choose two or four space indentation. Keep or force string quotes. Keep collection style, or switch maps and lists to block or flow notation. Set a preferred line width.

YAML 1.2 rules

Formatting uses the YAML 1.2 core schema with strict syntax and duplicate key checks. It changes how the file looks, not the values your app reads.

Frequently asked questions

Are comments kept character for character?

Comment text and placement are kept, but the whitespace around them can move.

Will forcing quotes affect mapping keys?

No. Keys keep their existing style. The quote setting applies to values.

Can it format a --- document stream?

Yes. Each document is formatted and the --- separators are kept.

Sources & last verified

We checked this tool's behavior and the claims on this page against the specifications below on . The tool runs in your browser, so the output you see is exactly what the engine produced.

Found a wrong result or an outdated claim? Report an error and we will check it again.