YAML Formatter
Paste YAML and get a formatted or compact copy in this tab. js-yaml parses it with the same default schema as YAML to JSON. Comments and some tags are not preserved. Nothing is uploaded.
YAML
Formatted YAML
How to use YAML Formatter
- Paste or open YAMLType, paste, or open a .yaml or .yml file. The limit is 2 MB of text, or 8 MB if you load a file.
- Choose format optionsPick an indent of 2 or 4 spaces, compact flow style, or key sorting. Turn on “all documents” if the file uses --- separators.
- Copy or downloadCopy the result or download formatted.yaml. If the YAML is invalid, the error from js-yaml is shown instead.
Limits and how it works
- The input is limited to 2 MB of UTF-8 text (8 MB if you load a file). Larger files can run out of memory in a phone browser tab.
- Comments are dropped. Custom tags and some merge-key cases are not supported.
- Anchors are resolved when the file is read. The output expands aliases instead of keeping the original anchor names (js-yaml dump uses noRefs).
- A syntax error is reported with the message from js-yaml; the file is not repaired automatically.
What this formatter changes
This page formats YAML. It does not convert YAML to JSON; use YAML to JSON for that, or JSON to YAML to go the other way.
Formatting uses js-yaml (MIT) with the default schema already used on YAML to JSON. Unquoted true and false become booleans. Unquoted yes, no, on, and off stay text, and are written in quotes so other YAML 1.1 parsers do not read them as booleans. The text is parsed and written back, so comments, original anchor names, and custom tags are not kept.
Compact mode writes flow-style YAML (braces and brackets). Block style with 2- or 4-space indent is the default pretty-print.
Frequently asked questions
Is my text or file uploaded?
No. Everything runs in your browser tab with JavaScript. Nothing you type, paste or drop is sent to a server, logged or stored by ALink Tools.
Why did my comments disappear?
js-yaml parses YAML into values and dumps them again. Comments and some styling are not part of that data and cannot be written back.
Can I format several documents at once?
Yes. Turn on “all documents” and a --- separated stream is formatted document by document.
Is this the same as YAML to JSON?
No. That page converts to JSON. This page writes YAML back out, with indent, compact, and sort-key options.
Related tools
All toolsYAML to JSON
Convert YAML to JSON in your browser with js-yaml. Read multiple documents in one file and get an error for duplicate keys.
JSON to YAML
Convert JSON to YAML in your browser with js-yaml. Set the indentation and sort keys if you need a consistent output.
JSON Formatter & Validator
Format, minify, sort keys, and catch syntax errors cleanly.
XML Formatter
Pretty-print or minify XML in your browser, without sending it to a server.