About Online YAML Formatter
The YAML Formatter converts poorly formatted YAML into a human-readable format and keeps its comments, quotes and key order. Use it on a Kubernetes manifest, a docker-compose file, a Helm values file or a GitHub Actions workflow.
- Re-indent YAML
- Keep comments, quotes and key order
- Keep anchors, aliases and tags such as
!Ref - Format every document of a file split by
--- - Highlight syntax errors with a built-in YAML linter
- View the YAML structure as a tree
- Upload a .yaml or .yml file from your disk
- Download the formatted YAML as a .yaml file
- Free to use
What is YAML formatting?
YAML formatting rewrites YAML with the same indentation at every level and the same spacing around colons and dashes. Keys, values and comments do not change.
Why format YAML?
In YAML, indentation is structure: a key indented one level deeper belongs to another mapping. A file edited over time mixes indentation widths and puts list items at different depths. That makes the structure hard to read and the diffs of the file noisy.
Is a YAML beautifier the same as a YAML formatter?
Yes. Beautify, prettify and format name the same operation: rewriting YAML with even indentation and spacing. The data does not change.
How to format YAML online?
Paste your YAML code, or press Upload to open a .yaml or .yml file, then press Format. Copy the result or press Download to save it as data.yaml. Invalid YAML is not formatted: the result lists every syntax error with its line and column, and the editor scrolls to the first one. To check YAML without formatting it, use the YAML Validator.
How does the YAML formatter work?
The page first checks that the YAML is valid. Invalid YAML is not formatted: you get every syntax error with its line and column. Valid YAML is re-indented, with its comments, quotes and lists in brackets kept. Long lines are not wrapped, and long integers keep every digit. Nothing is sent to the server.
YAML Format Example
In the YAML below, the levels are indented too deep, and the list item starts at the column of its key. The formatter re-indents it and keeps both comments and both kinds of quotes.
YAML Formatting Rules
- Every level gets the same indentation, and list items are indented under their key.
- Comments stay where they were, with one space before an inline
#. - Single and double quotes stay as written.
- Lists and mappings in brackets stay in brackets:
[a,b]becomes[ a, b ]. - Anchors, aliases and tags such as
!Refstay as written. - Long lines are not wrapped.
- Several documents keep their
---separators.
Online JSON Formatter
YAML is a superset of JSON, and the same data can be presented in both formats; the YAML to JSON Converter converts YAML data to JSON. To format JSON with spaces or tabs and view it as a collapsible tree, use the JSON Formatter.