Prettify YAML
Paste or upload YAML to format it with proper indentation and clean structure
Paste messy YAML, pick your indent size, and get a cleanly formatted version back in one click — the parser also flags syntax errors on the spot so you catch problems before your CI pipeline does. Handles Docker Compose files, Kubernetes manifests, GitHub Actions workflows, and any other YAML you throw at it. And everything runs in your browser. Nothing gets uploaded.
How It Works
The tool feeds your input into js-yaml, a full YAML parser that builds an internal data tree. Then it serializes that tree back out with the indent width you picked — 2 or 4 spaces, applied uniformly at every nesting level. If the parser hits a syntax problem (bad indentation, a missing colon, duplicate keys), it stops and shows you the exact line. No guesswork.
Examples
Fixing Inconsistent Docker Compose Indentation
A teammate edited docker-compose.yml with different editors and the spacing is all over the place.
services:
web:
image: nginx:latest
ports:
- "80:80"
db:
image: postgres:15
environment:
POSTGRES_DB: app
services:
web:
image: nginx:latest
ports:
- '80:80'
db:
image: postgres:15
environment:
POSTGRES_DB: app
Cleaning Up a Kubernetes Deployment
Copied a snippet from Stack Overflow and the nesting got mangled during paste.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
labels:
app: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
labels:
app: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
Quick GitHub Actions Cleanup
Short workflow file that just needs consistent 2-space indent.
name: CI
on: push
jobs:
build:
runs-on: ubuntu-latest
name: CI
on: push
jobs:
build:
runs-on: ubuntu-latest
Who Uses This
Cleaning up Kubernetes manifests, Helm charts, and Ansible playbooks before committing.
Formatting API config files and Docker Compose setups so the whole team reads them the same way.
Fixing indentation in homework YAML files when they can’t figure out why the parser keeps failing.
Standardizing GitHub Actions and GitLab CI workflows so linting passes on the first push.
Common Mistakes
YAML strictly forbids tabs for indentation. If your file has even one tab character, the parser will throw an error. Switch your editor to “spaces only” mode, or run a find-and-replace for tabs before pasting.
The prettifier parses YAML into a data structure and writes it back. Comments get dropped during that step — they’re not part of the data model. If your comments matter, back up the file first.
Valid JSON is technically valid YAML (YAML is a superset), so it won’t error out. But you’ll get YAML-formatted output, not prettified JSON. If you want JSON formatting, use a JSON formatter instead.
Writing key:value without a space after the colon is invalid YAML. It has to be key: value. The parser will flag this, but people paste it in and wonder why it fails. Always space after colons.
Technical Details
- Processing: 100% client-side — nothing leaves your browser
- Parser: js-yaml library (full YAML 1.2 spec support)
- Indent Options: 2 spaces or 4 spaces
- Browser Support: Chrome, Firefox, Safari, Edge
- Max Input: Limited only by your browser’s memory
Frequently Asked Questions
How do I prettify a YAML file online?
Paste your YAML into the input box on this page and click Prettify. The tool parses it and outputs a version with clean, consistent indentation. You can pick 2 or 4 spaces — most projects use 2.
What is the difference between YAML prettify and YAML validate?
Validation only checks if your YAML is syntactically correct. Prettifying goes further — it reformats the structure with uniform indentation and spacing. This tool does both at once: if the YAML is broken, you get an error; if it’s valid, you get a clean version back.
Does YAML prettify remove comments?
Yes. Standard YAML parsers don’t include comments in the parsed data structure, so when the data gets re-serialized, comments are lost. This is true of almost every YAML prettifier, not just this one. Save a copy of your original file if the comments are important.
Can I use tabs in YAML?
No. The YAML spec explicitly bans tab characters for indentation. Spaces only. If you paste YAML with tabs, the parser will reject it. Most code editors have a setting to insert spaces when you press Tab — turn that on for .yaml files.
Is 2-space or 4-space indent better for YAML?
Two spaces is the standard in most ecosystems — Kubernetes, Docker, GitHub Actions, and Ansible all default to it. Four spaces works fine too, but deeply nested files get wide fast. Stick with whatever your team already uses; if you’re starting fresh, go with 2.