YAML Formatter
Paste YAML and get it back with consistent indentation and block style, ready to commit. Prettify parses the document first, so a syntax error is reported with its line and column before anything is rewritten, and formatting never changes what the YAML means.
What formatting changes
Prettify reads the YAML into data and writes the data back in one consistent style. Indentation becomes two spaces at every level. Flow style, such as {host: localhost} or [search, export], becomes block style with one key or item per line. List items line up under their key.
A string keeps its quotes only when YAML needs them, for example when the value would otherwise read as a number, a boolean, or a date. Quotes are written as single quotes.
Key features
The formatter is strict about syntax, so a file that formats cleanly also parses cleanly in your tools.
- Two-space indentation and block style throughout.
- Quotes kept where they protect a value, such as 'yes' and '1.10', and removed where they do not.
- A tab in the indentation is an error, with its line and column.
- A duplicated key is an error, with its line and column.
- Nothing is formatted until the whole document parses.
- Download saves the result as prettify.yaml.
How to format YAML
Format in the box on this page, or in the editor for a larger file. The box takes documents up to 512 KB.
- Paste your YAML into the box labeled "Paste your YAML", or select "Try an example".
- Read the formatted YAML in the result panel, or the line and column of the first error.
- Select Copy to put the result on the clipboard, or Download to save it.
- Select "Open in full editor" to edit the YAML in the Raw view, browse it in the Tree view, or convert it to JSON.
Worked example: an app config
The config below mixes flow style and block style, and has extra spaces after one key. The second block is the result from the box.
The server mapping and the features list are in block style. The quotes around yes and 1.10 stay, because without them a YAML reader would get a boolean and the number 1.1. The quotes around a plain word would be removed. The extra spaces after retries are gone.
server: {host: localhost, port: 8080}
features: [search, export]
enabled: "yes"
version: "1.10"
retries: 3
server:
host: localhost
port: 8080
features:
- search
- export
enabled: 'yes'
version: '1.10'
retries: 3Limits to know
The output is written from the parsed data, and YAML parsers do not keep comments. Comments are not in the formatted YAML, so format a copy when your comments matter.
A file with several documents separated by --- formats one document in the box: the first. A note above the result says how many documents the file holds. The editor reads every document and lets you switch between them.
Check it before you deploy
A YAML file with a tab in its indentation, a misaligned key, or a duplicated key can deploy with the wrong values, or fail in a pipeline. Format the file before you commit it. Use the YAML Validator for a check that changes nothing.
Common uses
Consistent YAML makes reviews shorter, because a diff shows changes to values instead of changes to layout.
- Clean up a Kubernetes manifest or a Helm values file before you commit it.
- Format a CI workflow, such as a GitHub Actions file, that was edited by hand.
- Turn flow-style YAML from a tool or a generator into block style that people can read.
- Find the line of a syntax error that a deploy tool reports without a position.
Frequently asked questions
Does the formatter keep comments?
No. The output is written from the parsed data, and YAML parsers do not keep comments. Format a copy when your comments must stay.
Is my YAML uploaded?
No. Parsing and formatting run in your browser, so secrets in a config file or a manifest never leave your device.
Can it format a file with several documents?
The box formats the first document and says how many the file holds. Open the file in the editor to read and switch between every document.
Why are some values quoted?
YAML reads unquoted yes, no, on, and off as booleans in some parsers, and 1.10 as the number 1.1. The quotes keep those values as text.
Can I convert the YAML to JSON?
Yes. The YAML to JSON page converts it in one step, and the editor converts between YAML, JSON, XML, and CSV.
Is the YAML formatter free?
Yes. Formatting, validating, and converting YAML are free, with no account and no limit on use.
Does formatting change the order of keys?
No. Keys stay in the order they have in your file. Only the layout changes: indentation, block style, and quotes.
What happens to anchors and aliases?
They are expanded. Each alias is replaced by a copy of the value its anchor points to, and the anchors are not in the output. Keep the original when your file uses anchors to share a block between keys.