YAML Formatter
Converters & FormattersValidate YAML and rewrite it in canonical form: consistent 2-space indentation, sorted-out quoting, anchors and merge keys resolved to plain data. Errors report position, never guesswork. Runs entirely in your browser.
What it does
Rewrites any YAML document in canonical form: consistent 2-space indentation, normalized quoting, and long lines kept intact (no surprise word-wrapping that pollutes diffs). The input is parsed first, so the output is guaranteed to be valid YAML carrying identical data — anchors and merge keys (<<: *ref) are resolved into plain values, which is usually what you want when handing YAML to another tool. Invalid input produces a red error box with the parser’s position information, never guessed-at output. Everything runs locally in your browser.
How to use it
- Paste YAML into YAML input (left), or tap a chip under Try: — Messy indent, Anchors & merge, or List of maps. Sample loads a small service config; Clear empties the box.
- The canonical document appears live in Canonical YAML (right), with a badge reporting the output’s line count.
- Copy takes the output; Download saves it as
formatted.yaml(offered only when the input is valid). - Copy share link encodes your input in the URL — opening that link restores it exactly.
Examples
Tap Sample:
server: port 8080, tags prod + edge → re-indented to 2 spaces, list items aligned, one trailing newline.
The Anchors & merge chip shows the resolution rule — base: &b with service: <<: *b becomes two independent plain mappings; the anchor and merge keys disappear from the output.
The Messy indent chip collapses 6-space and 4-space nesting into uniform 2-space levels, and the inline list [a, b] stays inline.
Good to know
- Merge keys are YAML 1.1 behavior; the formatter resolves them like modern parsers do, so the output is what
yaml.safeLoad-style loaders see. - Flow style (
{a: 1}) in the input is preserved as flow style; block style input stays block. - The output always ends with exactly one newline — friendliest shape for
git diff. - Nothing is sent anywhere: formatting is pure client-side JavaScript.