Tools

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

Minify YAML

Remove comments and unnecessary whitespace from YAML while keeping it valid

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

Paste bloated YAML — full of stale comments, blank lines, and 4-space indents nobody asked for — and get a compact, valid version back in one click. The parser strips what isn’t data and rewrites the rest at your chosen indent level, often cutting file size by 40-60%.

And everything runs in your browser. Nothing gets uploaded.

How It Works

Paste YAML
→
Parse & Strip
→
Compact Output

The tool feeds your YAML through the js-yaml parser, which builds a proper JavaScript object from it. Comments and whitespace don’t survive parsing — they’re not part of YAML’s data model. Then it serializes the object back to YAML with your chosen indent level. The result is structurally identical to the original, just without the fluff.

Examples

Cleaning up a Docker Compose file

Someone left comments on every line during code review. Time to ship.

INPUT
# Main web service services: web: # Use latest nginx image: nginx:latest ports: - "80:80" # HTTP - "443:443" # HTTPS # Mount config volumes: - ./nginx.conf:/etc/nginx/nginx.conf
OUTPUT
services: web: image: nginx:latest ports: - "80:80" - "443:443" volumes: - ./nginx.conf:/etc/nginx/nginx.conf

Shrinking a CI pipeline config

A GitHub Actions workflow with generous spacing and TODO comments cluttering the diff.

INPUT
name: CI on: push: branches: - main # TODO: add caching jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install run: npm install - name: Test run: npm test
OUTPUT
name: CI "on": push: branches: - main jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install run: npm install - name: Test run: npm test

Compact mode for an API response mock

You need YAML test fixtures as small as possible so they don’t bloat your test files.

INPUT
user: id: 42 name: Jane Doe email: [email protected] roles: - admin - editor settings: theme: dark notifications: true
OUTPUT
{user: {id: 42, name: Jane Doe, email: [email protected], roles: [admin, editor], settings: {theme: dark, notifications: true}}}

Who Uses This

🛠️ DevOps Engineers

Trim Kubernetes manifests and Helm charts before deploying to keep image layers small.

👨‍💻 Backend Developers

Clean up Spring Boot or Rails config files that have accumulated stale comments over months.

🔄 CI/CD Maintainers

Strip TODO comments and whitespace from pipeline configs before merging to main.

📊 Data Engineers

Compact YAML fixtures and test data files that get loaded into automated test suites.

Common Mistakes

Expecting comments to survive

YAML comments aren’t part of the data model. When the parser builds an object from your file, comments vanish — there’s no way to keep them. If you need those notes, save a copy of the original first.

Using compact mode on deeply nested configs

Compact (0-indent) mode dumps everything in flow style — curly braces and brackets on one line. Great for flat structures, but a 10-level-deep Kubernetes spec becomes unreadable. Stick with 2-space indent for complex files.

Minifying YAML with anchors and aliases

The parser resolves anchors (&name) and aliases (*name) into their actual values. Your output won’t have those references anymore — it’ll have duplicate data instead. If you rely on anchors to keep your config DRY, minifying will expand them.

Technical Details

Frequently Asked Questions

What does minifying YAML actually do?

It strips out comments, blank lines, and extra whitespace. The parser reads your YAML into a data structure, then writes it back with minimal formatting. Your data stays the same — the file just gets smaller.

Is the minified output still valid YAML?

Yes. The tool doesn’t do string manipulation — it fully parses the YAML and re-serializes it. If your input was valid, the output will be too. Any parser that reads YAML 1.2 will handle it fine.

Can I keep my comments when minifying?

No. YAML comments exist only in the text file — they’re not part of the data. Once the parser builds an object, comments are gone for good. If you need them, keep an unminified copy around.

How much smaller will my YAML file get?

Depends on how many comments and blank lines you had. A heavily commented config file can shrink 40-60%. A file that was already clean might only lose 5-10%. The tool shows you exact byte counts and percentage after minifying.

Is my YAML data sent to a server?

Not at all. Everything happens in your browser with JavaScript. Open your network tab if you want proof — you won’t see a single request when you click Minify. Your config files stay on your machine.

Share: