YAML Formatter
Format and beautify YAML with the indentation you prefer.
Input YAML
Formatted YAML
Features
- Format and pretty-print YAML with configurable indentation (2 or 4 spaces)
- Remove redundant quotes and normalize boolean values
- Sort keys alphabetically (optional)
- Syntax error detection with line/column reporting
- Side-by-side before/after comparison
- Copy formatted output to clipboard with one click
Common Use Cases
- Clean up auto-generated or minified YAML from CI/CD pipelines
- Standardize indentation across team configuration files
- Pre-process YAML before committing to a repository
- Format Kubernetes manifests and Helm values files for readability
- Normalize whitespace and quoting style in Ansible playbooks
What is YAML?
YAML (YAML Ain't Markup Language) is a human-friendly data serialization format widely used for configuration files. Its key strength is readability — indentation defines structure, and documents are written in plain text without angle brackets or braces.
Well-formatted YAML is essential: a single wrong indent can cause a parse error or, worse, silent mis-configuration. Consistent formatting across a team prevents merge conflicts and makes code reviews easier.
YAML is a superset of JSON, meaning any valid JSON is also valid YAML. It supports scalars (strings, numbers, booleans, null), sequences (lists), and mappings (key-value objects) as its core data types.
Examples
server:
host: localhost
port: 8080
debug: trueserver:
host: localhost
port: 8080
debug: true---
name: app-v1
---
name: app-v2Frequently Asked Questions
YAML uses indentation to represent nesting — unlike JSON which uses braces. A wrong level of indentation changes the structure of your data. For example, moving a key one level deeper makes it a child of the previous key instead of a sibling. This is often the root cause of "unexpected token" errors in Kubernetes or Docker Compose files.
YAML forbids tab characters for indentation. You must use spaces. Mixing tabs and spaces is a guaranteed parse error. Most editors have an option to convert tabs to spaces automatically — enable it for YAML files.
YAML itself does not mandate a specific number — any consistent number works. However, 2 spaces is the dominant convention (used by Kubernetes, GitHub Actions, Docker Compose, Ansible). Use 4 spaces only if your team or tooling requires it.
The --- marker denotes the start of a new YAML document within a single file. Some tools (like Kubernetes) support multi-document YAML files where different resources are separated by ---. The ... marker denotes end-of-document.
Yes! YAML supports single-line comments starting with #. Unlike JSON, comments are preserved when editing manually. However, most parsers discard comments when loading YAML into memory, so they are lost during programmatic round-trips (parse → serialize).
💡 Tips
- Enable "format on save" in your editor for YAML files — it prevents accidental indent drift over time.
- Use consistent quoting: either always quote strings or never quote them (except when necessary for special characters).
- Run the formatter as a pre-commit hook (e.g., via <code>prettier --write</code> or <code>yamlfmt</code>) to enforce consistency automatically.
- Avoid trailing whitespace — it can cause issues with some parsers and adds noise to diffs.