YAML Formatter
Format and normalise YAML online with consistent indentation using Prettier. Clean up Kubernetes, Docker Compose and CI config files in your browser.
Runs in your browser · Nothing uploadedFree · No sign-up
Something not working, or missing a feature? Send feedback
About the YAML Formatter
Inconsistent indentation is the most common cause of broken YAML. The YAML Formatter normalises indentation and spacing with Prettier so configuration files stay readable and valid. Use it to fix YAML indentation in .yml files (YML and YAML are the same format): if the file does not parse, the error shows the line to fix first.
Everything runs in your browser, so your input is never uploaded to a server.
How to use the YAML Formatter
- Paste YAML or open a .yml/.yaml file.
- Review the formatted output.
- Copy or download it.
Example
Input
services:
web:
image: "nginx:1.27"
ports: [ "80:80", "443:443" ]
environment:
- TZ=UTC # server time
db:
image: postgres:16Result
services:
web:
image: "nginx:1.27"
ports: ["80:80", "443:443"]
environment:
- TZ=UTC # server time
db:
image: postgres:16
Indentation becomes two spaces at every level, flow sequences are spaced consistently and the comment stays on its line. The data itself is unchanged.
Common mistakes
- Tabs for indentation. YAML does not allow tab characters for indentation. Replace them with spaces; the error message points to the first tab.
- Unquoted colons in values. A value such as title: Note: read me is ambiguous. Quote it ("Note: read me") so the second colon is part of the string.
- Formatting a templated file. Helm charts and other templates with {{ }} placeholders are not valid YAML until rendered. Format the rendered output, or the plain values file.
Works well with the YAML Formatter
- YAML Validator: see how each value is interpreted, as JSON.
- YAML to JSON: convert the file for an API or JSON Schema check.
- Text & Code Diff: compare two versions of a config file.
Frequently asked questions
Are comments preserved?
Yes. Comments stay attached to the lines they describe.
Can it convert YAML to JSON?
Use the YAML to JSON converter for that; this tool keeps the format as YAML.
Does it change quoting?
Prettier keeps your values but may switch between single and double quotes where both mean the same string. Values are never unquoted if that would change their type.
Are multi-document files supported?
Yes. Documents separated by --- are each formatted and kept in order.
Guides and tutorials
Related tools
JSON Formatter
Format and beautify JSON with configurable indentation and optional key sorting. Errors are reported with exact line and column.
HTML Formatter
Format and beautify messy or minified HTML into clean, indented markup with Prettier, including embedded CSS and JavaScript. Runs locally in your browser.
CSS Formatter
Format and beautify CSS, SCSS and Less online with Prettier. Turn minified or messy stylesheets into readable, consistently indented code in your browser.
JavaScript Formatter
Format and beautify JavaScript and JSX online with Prettier. Choose indentation, quotes, semicolons and line width; your code is formatted in your browser.
TypeScript Formatter
Format and beautify TypeScript and TSX online with Prettier, including types, generics and decorators. Choose indentation, quotes and semicolons.
PHP Formatter
Format PHP code online with Prettier for PHP (@prettier/plugin-php): PSR-12 braces, spacing and 4-space indentation. No install, and nothing is uploaded.