Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

YAML Indentation Fixer & Prettifier

Paste messy or broken YAML to fix indentation, validate syntax, and prettify with configurable options

Your files never leave your browser
Input0 chars, 0 lines
Output0 chars, 0 lines
Ready·

Paste broken or messy YAML, pick your indent size, and get clean, consistently spaced output in one click — the tool re-parses the whole document and rebuilds it with uniform indentation. It also catches syntax errors on the spot, so you know immediately if something is genuinely broken or just ugly. And everything runs in your browser. Nothing gets uploaded.

How It Works

Paste Messy YAML
→
Parse & Rebuild AST
→
Clean, Indented Output

The tool uses the js-yaml library to parse your input into a data structure (think of it like a tree of keys, values, and lists). Then it serializes that tree back into YAML text using your chosen indent size and flow settings. Because it rebuilds from the parsed data, every line gets uniform spacing — no guesswork, no regex hacks.

Examples

Fixing a Docker Compose File

Someone copy-pasted from a tutorial and the indentation got mangled.

INPUT
services: web: image: nginx:latest ports: - "80:80" db: image: postgres:15 environment: POSTGRES_PASSWORD: secret
OUTPUT
services: web: image: nginx:latest ports: - "80:80" db: image: postgres:15 environment: POSTGRES_PASSWORD: secret

Converting Flow Style to Block Style

A CI pipeline config written in compact JSON-like flow style that nobody can read anymore.

INPUT
jobs: {build: {runs-on: ubuntu-latest, steps: [{uses: actions/checkout@v4}, {run: npm install}, {run: npm test}]}}
OUTPUT
jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npm install - run: npm test

Cleaning Up a Kubernetes Deployment Manifest

Exported from kubectl with mixed 2-space and 4-space indentation, plus some inline arrays that should be expanded.

INPUT
apiVersion: apps/v1 kind: Deployment metadata: name: my-app labels: {app: my-app, env: prod} spec: replicas: 3 template: spec: containers: - name: app image: myrepo/app:v2.1 ports: [{containerPort: 8080}]
OUTPUT
apiVersion: apps/v1 kind: Deployment metadata: name: my-app labels: app: my-app env: prod spec: replicas: 3 template: spec: containers: - name: app image: myrepo/app:v2.1 ports: - containerPort: 8080

Who Uses This

👨‍💻 DevOps Engineers

Cleaning up Kubernetes manifests, Helm charts, and Ansible playbooks before committing to version control.

🔧 Backend Developers

Formatting Docker Compose files and Spring Boot application.yml configs that got messy during debugging.

🎓 Students

Learning YAML syntax by seeing how the prettifier restructures their broken files — it is a surprisingly good teacher.

🚀 CI/CD Pipeline Authors

Making GitHub Actions and GitLab CI configs readable for the whole team before code review.

Common Mistakes

Mixing tabs and spaces

YAML doesn’t allow tabs for indentation. Period. If your editor inserts a tab character, the parser will reject it even though it looks fine on screen. Switch your editor to “spaces only” mode before writing YAML.

Forgetting to quote strings with special characters

A value like password: p@ss:word! will fail because colons and certain symbols have meaning in YAML. Wrap it in quotes: password: "p@ss:word!". The prettifier won’t add quotes for you since it can’t know your intent, but the validation error will point you to the exact line.

Assuming the prettifier preserves comments

Most YAML parsers — including this one — strip comments during parsing. If you have important # TODO or # explanation comments, copy them somewhere first. The data stays intact, but comments don’t survive the round-trip.

Technical Details

Frequently Asked Questions

What does a YAML prettifier actually do?

It parses your YAML into a data structure (think of it like a tree), then writes it back out with clean, consistent indentation. The data itself doesn’t change — just the formatting. Broken spacing, misaligned keys, and inconsistent nesting all get fixed in the process.

Will this tool remove my YAML comments?

Yes, unfortunately. The js-yaml parser discards comments during parsing because they aren’t part of the data model. This is a known limitation of most YAML libraries. If you have comments you want to keep, save them separately before prettifying.

What’s the difference between block style and flow style?

Block style is what most people think of as “normal YAML” — each item on its own line, nested with indentation. Flow style looks more like JSON, with curly braces and brackets on one line. Block is easier to read; flow is more compact. The flow level setting controls how deep nesting goes before switching styles.

Can I use tabs in YAML?

No. The YAML spec explicitly forbids tab characters for indentation. Only spaces are allowed. This trips up a lot of people coming from languages where tabs work fine. If you paste YAML with tabs, the parser will throw an error before it can prettify anything.

Is my data safe? Does anything get sent to a server?

Nothing gets uploaded. The entire tool runs in your browser using JavaScript. You can disconnect from the internet and it’ll still work. Your YAML configs, credentials, and environment variables stay on your machine the whole time.

Share: