01What is CSS Minifier?
Sometimes you just need a smaller stylesheet right now. Maybe it's a critical-CSS block going into a style tag, or a snippet for a CMS field with a character limit. You don't want to set up a build step for that. The CSS Minifier shrinks CSS as you type and shows exactly how many bytes you saved. It works on tokens rather than raw text. The input is first split into comments, quoted strings, unquoted url() values, punctuation and words. Only then does the tool decide which gaps can go. The rules for that come from the W3C CSS Syntax Module Level 3, which defines where whitespace is significant in CSS. So here is what gets removed: comments, line breaks, indentation, spaces around braces, semicolons, commas and declaration colons, spaces around the selector combinators >, + and ~, the space before !important, and the last semicolon in each block. And here is what is left alone. Quoted strings are copied byte for byte, even if they contain something that looks like a comment. Unquoted url() values are kept whole, so a semicolon inside a data URI is safe. Comments that start with /*! are kept, which is the usual marker for license text. The space in .card :is(.a) stays because it's a descendant combinator. Spaces around + and - inside calc(), min(), max() and clamp() stay too, since the CSS Values spec requires them there. A worked example. Paste a { color: red; } then a /* note */ comment, then b { margin: 0 auto ; }. That's 51 bytes. The output is a{color:red}b{margin:0 auto}, which is 28 bytes. The Savings box shows 45.1%. Sizes are measured as UTF-8 bytes, so non-ASCII characters in content strings count correctly. Be clear about the scope. This is whitespace and comment removal only. It doesn't shorten #ffffff to #fff, merge duplicate selectors, collapse margin shorthands, drop unused rules or write source maps. For a full production pipeline, a build-step optimizer such as cssnano or Lightning CSS does that structural work. The tool also doesn't validate your CSS. If a brace is missing, the output will be missing it too. Your CSS never leaves the tab. The minifying runs in the page's JavaScript, so pasting unreleased styles is fine.
Frontend developers who need a quick minified copy of a small stylesheet for inlining, an email template or a size-limited CMS field. The tool runs entirely in your browser, so your data never leaves your device.
02How to use CSS Minifier
- Paste your CSS into the Input CSS box
- Watch the Minified CSS output update as you type
- Check the Original Size, Minified Size and Savings figures
- Click Copy above the Minified CSS output
- Click Reset to clear the input and start again
03Worked examples
- Input:
a { color: red; } /* note */ b { margin: 0 auto ; } - Result:
a{color:red}b{margin:0 auto} - 51 B down to 28 B, shown as 45.1% savings. The space in 0 auto stays because it separates two values.
- Input:
.x { width: calc(100% - 2rem); } - Result:
.x{width:calc(100% - 2rem)} - Spaces around - inside calc() are required by CSS, so they are kept.
- Input:
a > b + c ~ d { color : #fff !important ; } - Result:
a>b+c~d{color:#fff!important} - Spaces around selector combinators and before !important are dropped.
- Input:
.card :is(.a, .b) { color: red; } - Result:
.card :is(.a,.b){color:red} - The space before :is is a descendant combinator, so removing it would change the selector.
- Input:
/*! MIT */ .a { color: red; } - Result:
/*! MIT */ .a{color:red} - Comments starting with /*! are kept. The line break after it becomes a single space.
- Input:
@media (min-width: 768px) and (max-width: 1024px) { .a { display: none; } } - Result:
@media (min-width:768px) and (max-width:1024px){.a{display:none}} - The spaces around and are kept because media query syntax needs them.
04Common use cases
- Minifying a critical-CSS block before inlining it in a style tag in the HTML head
- Fitting custom CSS into a CMS, theme setting or embed field that has a character limit
- Shrinking styles for an HTML email where every byte of the message counts toward clipping limits
- Seeing how much of a hand-written stylesheet is just comments and indentation
- Removing internal TODO comments from CSS before sharing it with a client, while keeping a /*! license header
- Comparing byte sizes before deciding whether a stylesheet is worth adding to a build pipeline
05Tips
- Write license headers as /*! ... */. Those survive while ordinary comments are stripped.
- Low savings on an already tidy file is normal. Most of the gain comes from indentation and comments, not from the CSS itself.
- Gzip or Brotli on the server does far more for transfer size than minification alone, so do both.
- Keep the readable source in your repo and minify a copy. Editing minified CSS by hand is how bugs sneak in.
06Related concepts
CSS optimization, Source maps, Critical CSS, Gzip compression.
Frequently Asked Questions
What is CSS Minifier?
CSS Minifier is a free, browser-based developer tool on AIDToolStack. Minify CSS by removing comments and insignificant whitespace. It requires no installation or sign-up and works entirely in your browser.
Is CSS Minifier free to use?
Yes. No sign-up, no fees and no usage cap.
Does CSS Minifier store my data?
No. It runs in your browser; nothing is uploaded.