JavaScript & CSS Minifier

Paste JavaScript or CSS and shrink it by stripping comments, whitespace and line breaks — with a one-line before/after size report. Auto-detects the language, keeps license banners, and never rewrites values. Runs in your browser; nothing is uploaded.

Try:
Minified code

About this tool

JavaScript & CSS Minifier shrinks either JavaScript or CSS by removing everything that doesn't change how it behaves — comments, whitespace and line breaks — and shows you exactly how many bytes you saved.

Everything runs locally in your browser via WebAssembly — your code is never uploaded.

Worked example

Paste this CSS with Language = CSS, Remove comments on and Prepend size report on:

.card {
  margin: 0 auto;   /* center it */
  color: #ff0000;
}

.card > .title {
  font-weight: bold;
}

You get:

/* CSS: 98 B -> 63 B — 35.7% smaller (saved 35 B) */
.card{margin:0 auto;color:#ff0000}.card>.title{font-weight:bold}

Whitespace collapses, the trailing ; before each } is dropped, the > combinator loses its spaces, and the ordinary /* center it */ comment is stripped — but #ff0000 is left exactly as written.

FAQ

How does auto-detect decide between JavaScript and CSS?

It scores the source on language markers — JavaScript signals like function, =>, const, ===, console. versus CSS signals like @media, :root, !important, units (px, rem) and selector { prop: value; } blocks. If the CSS signals clearly win it minifies as CSS, otherwise as JavaScript. Real-world JS and CSS separate cleanly; if a tiny or unusual snippet ever guesses wrong, just set Language to CSS or JavaScript explicitly.

Does it rename variables or rewrite CSS values like a heavy minifier?

No. This is a whitespace/comment minifier, not a name-mangler or value optimizer. JavaScript identifiers are never renamed and no code is reordered or dropped. CSS values are left byte-for-byte — it will not shorten #ffffff to #fff, strip leading zeros, or merge rules. That keeps the output guaranteed equivalent to the input, which matters for hand-checked and vendor code. The result is a little larger than an aggressive optimizer would produce.

How do I keep a license or copyright banner?

Banners survive comment removal automatically: any /*! … */ block comment, or one containing @license or @preserve, is treated as important and kept even when Remove comments is on. This works for both JavaScript and CSS, since /* … */ is valid in both.

Can minifying break CSS like calc() or media queries?

No. The CSS minifier protects the inside of parentheses, so calc(100% - 10px) keeps its spaces (removing them would break it), and it only strips spaces around >, + and ~ at the top level where they're combinators — never inside a value. Strings and url(...) contents are emitted verbatim, and @media/@keyframes blocks minify normally.

Limits & notes

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool js-css-minifier ".card {
  margin: 0 auto;
  color: #ff0000;
}"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/js-css-minifier/?code=.card%20%7B%0A%20%20margin%3A%200%20auto%3B%0A%20%20color%3A%20%23ff0000%3B%0A%7D&language=auto&remove_comments=true&report=true

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.