Tools

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

Prettify YAML

Paste or upload YAML to format it with proper indentation and clean structure

Your files never leave your browser
YAML Input0 chars, 0 lines
Drag & drop a YAML file here, or browse
Accepts .yaml, .yml, .txt files
Prettified Output0 chars, 0 lines
Error:
    Ready·

    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

    Paste Raw YAML
    ➞
    Parse & Reformat
    ➞
    Clean Output

    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.

    INPUT
    services: web: image: nginx:latest ports: - "80:80" db: image: postgres:15 environment: POSTGRES_DB: app
    OUTPUT
    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.

    INPUT
    apiVersion: apps/v1 kind: Deployment metadata: name: my-app labels: app: my-app spec: replicas: 3 selector: matchLabels: app: my-app
    OUTPUT
    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.

    INPUT
    name: CI on: push jobs: build: runs-on: ubuntu-latest
    OUTPUT
    name: CI on: push jobs: build: runs-on: ubuntu-latest

    Who Uses This

    💻 DevOps Engineers

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

    👨‍💻 Backend Developers

    Formatting API config files and Docker Compose setups so the whole team reads them the same way.

    🎓 Students

    Fixing indentation in homework YAML files when they can’t figure out why the parser keeps failing.

    🚀 CI/CD Pipeline Authors

    Standardizing GitHub Actions and GitLab CI workflows so linting passes on the first push.

    Common Mistakes

    Mixing tabs and spaces

    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.

    Expecting comments to survive

    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.

    Pasting JSON instead of YAML

    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.

    Forgetting the colon-space rule

    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

    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.

    Share: