YAML Formatter & Validator
Free online yaml formatter & validator for developers. Validate and pretty-print YAML. Fast and private.
Embed this tool
Copy and paste the code below into your website to embed this tool for free. An attribution link to The Util Box is required.
<iframe src="https://www.theutilbox.org/embed/yaml-formatter" width="600" height="500" frameborder="0" style="border: none; max-width: 100%;" title="Free YAML Formatter & Validator tool from The Util Box"></iframe> <!-- Free tool by The Util Box — https://www.theutilbox.org/tools/yaml-formatter --> <a href="https://www.theutilbox.org/tools/yaml-formatter">YAML Formatter & Validator by The Util Box</a>
Frequently Asked Questions about YAML Formatter & Validator
YAML Formatter — Re-indent a Configuration File
This YAML formatter rewrites a YAML document with consistent two-space indentation. It works by parsing the YAML into a data structure and printing it back out, so the result is normalised rather than merely re-spaced.
The practical case is a file that has been edited by hand, or concatenated from several sources, where the indentation has drifted and the parser is complaining about it.
What Normalising Means Here
Because the formatter parses first, the output is canonical: every nesting level is indented by exactly two spaces, every list item sits on its own line with a dash, and every scalar is written in its simplest form.
Scalars are resolved to their types as part of the round trip. true and
false become booleans, null and
~ become null, anything numeric becomes a number, and quoted strings lose their
quotes.
Honest Limits
- Comments are lost. The formatter works on the parsed data, and comments
are not part of that — so every
#line in your file disappears. Back up anything with comments in it. - Quoted strings are unquoted on the way out, so a value that was deliberately quoted to stop it being read as a number or a boolean may come back unquoted.
- The YAML parser is a hand-written subset. It does not implement anchors
and aliases, multi-document files, block scalars (
|and>), tags or complex keys. - It is a formatter, not a linter. It will tell you the file could not be parsed, but it makes no judgement about style — use the YAML Lint for that.
Related Developer Tools
- YAML to JSON — the conversion the formatter performs internally.
- YAML Lint — check a file parses before formatting it.
- YAML Minifier — strip the whitespace and comments back out.
- YAML Path Query — pull one value out of the result.
- YAML to XML — the other structured format.
- JSON Formatter — the same job for JSON.
- JSON Minifier — for the other format.
- Dotenv Generator — a sibling format for environment variables.
The formatting runs entirely in your browser — your YAML is never uploaded.