YAML Formatter & Beautifier
Paste a YAML subset and reprint it with a consistent space indent. A successful result means that subset parsed, not that every YAML feature was checked.
About this tool
Beautify and pretty-print mean a reprint through the existing YAML reader and writer. The page does not add a second parser. Parsing checks that the text fits the subset. Writing then emits mappings, lists, and scalars with the indent you chose. That is formatting. It is not a promise that the file is valid YAML 1.2, and it is not the conversion to JSON. JSON YAML remains the tool that changes YAML into JSON or the other way around.
Use it to line up a small config, a list of mappings, or a document that has drifted into mixed spacing. Comments do not survive, because the subset reader skips them. A quoted string comes back quoted. Tabs are refused because YAML indentation is spaces.
The result stays YAML, so a later suggestion is whatever tool already accepts YAML. The source stays in this browser.
How to use it
- Paste YAML, or choose a local file. The file is read on this page and is not uploaded.
- Choose 2 or 4 spaces, then Format YAML. Ctrl+Enter or Cmd+Enter does the same thing from the box.
- Copy or download the reprint. Anchors, tags, and merge keys are rejected instead of being guessed.
Limitations
- Formatting reprints the same subset the JSON YAML tool parses. Comments are dropped. Anchors, tags, merge keys, and tab indentation are rejected.
- Block scalars and other YAML 1.2 forms outside that subset fail. Strings are reprinted with JSON-style quotes. A source longer than 1 MB is refused.
One document, loaded and printed again
Load, then dump, with a space indent
A load and a dump decide the new indent. The paste has to be one document that js-yaml can load. The dump then prints that value with an indent of two spaces or four spaces, and with line wrapping turned off so a long scalar is not folded to fit a column. Comments are not part of the loaded value, so they do not return. The original choice of quotes, the original position of dashes, and blank lines you used as visual grouping are replaced by the dump’s own spelling.
Tab indentation is outside this pass. If the indent control is set to tabs, the page stops before loading, because a tab is not a legal YAML indent. A tab already sitting at the start of a line in the paste is rejected as well. A tab that appears only inside a quoted scalar is a different matter: the failure rule looks for a tab at the beginning of a line. Empty input fails with a prompt to paste YAML, rather than printing an empty document.
The subset is the library’s subset
Anchors, tags, and merge keys are accepted when js-yaml understands them. An older printer on this project refused those constructs. This one does not keep that refusal. A tag the library’s schema does not know still fails, and a stream of two documents fails because load expects a single document. That is a subset of the YAML specifications, not a walk through every legal file. Success also does not mean a schema was applied. No JSON Schema, and no separate shape file, is compared to the value. Keys you did not expect are printed if the load succeeded.
What the round trip changes
Shared structure that the loader represents with repeated references may be written back with anchors, because the dump is allowed to emit references. A timestamp the loader turns into a time value can come back in the loader’s spelling rather than the characters you typed. A number written with a leading zero can come back without that zero. If you needed the original bytes, this page is the wrong tool. If you needed a stable indent for one document the library accepts, this is the pass that produces it.
Privacy
Your YAML is processed in your browser and is not uploaded to UtilChain. File names, source text, and results are not sent to analytics.

