YAML Beautifier and Formatter
FV-34Paste YAML to clean up its indentation and spacing. Comments, anchors, aliases and multiple documents are kept, which is the point of formatting instead of converting.
Runs in your browser. Nothing is uploaded.
YAML
Formatted YAML
How to use it
- Paste your YAML into the input box, or open a .yaml or .yml file.
- Pick 2 or 4 spaces for the indent. YAML does not allow tabs.
- Choose single quotes, brace spacing and wrapping if you need them.
- Copy the formatted YAML or download it as a .yaml file.
What it keeps
The formatter is Prettier's YAML printer. It parses YAML 1.2 and writes it back with consistent indentation, spacing and list layout. Comments, anchors, aliases, tags and multiple documents separated by --- are all kept. That separates it from converting to JSON and back, which drops comments and anchors. The data itself does not change.
What it changes
Indentation is set to your choice and list items are indented under their key. Extra spaces after colons and in flow lists such as [1, 2] are removed. Strings are written with double quotes, so single-quoted strings change unless you tick single quotes. Blank lines are kept, up to one in a row. Long text is left alone by default, and you can wrap it at a width or join it.
Limits
Invalid YAML is reported with its line and column and nothing is formatted. The check is for YAML syntax only: duplicate keys, wrong types and schema rules such as those for Kubernetes or GitHub Actions are not checked. YAML cannot be indented with tabs, so only space indents are offered. Multi-line values written as block scalars with | or > are kept as written.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Invalid YAML: Flow sequence in block collection must be sufficiently indented and end with a ] at line 2, column 1 | A [ list was opened and not closed before the next line started. | Add the closing ] or indent the continuation lines. |
Questions people ask
How do I format YAML online?
Paste the YAML and the formatted version appears as you type. Pick 2 or 4 spaces, then copy it or download it as a .yaml file. Comments and anchors are kept.
Does it keep comments?
Yes. Comments stay with the lines they were written beside. This is the main reason to use a formatter rather than a YAML to JSON converter, which cannot carry comments across.
Why did my single quotes become double quotes?
The formatter prefers double quotes and rewrites single-quoted strings to match. Tick Single quotes to prefer them instead. Strings that need escapes keep whichever form avoids backslashes, and the value never changes.
Can YAML use tabs for indentation?
No. The YAML specification forbids tabs for indentation, so the formatter offers 2 or 4 spaces only. If your file has tabs for indentation it will fail to parse and the error gives the line and column.
Does it handle multiple YAML documents?
Yes. Documents separated by --- are formatted one after another and the separators are kept. This is common in Kubernetes manifests and CI files, where one file holds several resources.
Does it validate my Kubernetes or CI config?
No. It checks YAML syntax only. It does not know the schema, so a wrong field name or value type is not reported. Use the tool's own validator, such as kubectl or your CI's linter, for that.
About this tool
Uses the Prettier YAML formatter, which parses YAML 1.2 and writes it back with consistent indentation and spacing. Comments, anchors, aliases, tags and multiple documents separated by --- are kept, which is the reason to pick this over converting to JSON and back. Quotes are normalized: Prettier prefers double quotes, so single-quoted strings change unless you tick single quotes. Blank lines are kept (at most one) and flow lists and maps may be reflowed. YAML cannot be indented with tabs, so there is no tab choice. Invalid YAML is reported with its line and column. The data is not changed, but duplicate keys and other schema problems are not checked.