What is CSS minification?
CSS minification makes a stylesheet smaller without changing how it renders. This free CSS minifier parses your CSS with PostCSS and minifies it with cssnano: it removes whitespace, comments, and the last semicolon in each rule, shortens colours and numbers, and merges duplicate rules, while strings, calc() expressions, selectors, and nesting keep their meaning. It runs entirely in your browser.
Why minify CSS
Minifying CSS strips the whitespace, line breaks, comments, and the final semicolon from each rule to produce a smaller stylesheet. Because CSS blocks page rendering until it loads, a smaller file means the browser can paint the page sooner — a direct improvement to perceived performance and Core Web Vitals.
The styling is unchanged: every rule still applies to the same elements with the same values, only written in fewer bytes.
What this minifier changes
Beyond whitespace and comments, cssnano rewrites values into shorter equivalents: #333333 becomes #333, 0.20s becomes .2s, 0px becomes 0, margin: 0 auto 0 auto becomes margin:0 auto, and font-weight: bold becomes 700. Rules with identical declarations are merged (.a{color:red}.b{color:red} becomes .a,.b{color:red}), exact duplicate rules are removed, and empty rules are dropped.
Every change is checked against all browsers with any recorded usage, so the minified CSS works everywhere the original did: vendor prefixes and fallback declarations are kept, and rules aren't merged when some browsers don't understand one of their selectors.
What stays exactly as written
Text inside strings (such as content values, quoted font names, and attribute selector values), calc() expressions, the space in descendant selectors such as .a :first-child, CSS nesting, and comments that start with /*! (licence comments) are kept. A minifier that only deletes spaces with find-and-replace can break all of these — for example turning calc(100% + 10px) into the invalid calc(100%+10px).
Syntax errors
If the CSS can't be parsed — an unclosed block, string, or comment, or a stray } — the minifier reports the line and column and what's wrong, and Go to error moves the cursor there, instead of producing broken output.
Minify at build time
Keep your source stylesheet formatted and readable, and minify as part of your build or deployment. Serving the minified file to users while editing the formatted one gives you both smaller downloads and maintainable code.
Minification and gzip together
Minification and server compression are complementary. Minifying strips comments and whitespace, then gzip or Brotli compresses the result further, so shipping minified CSS through a compressing server yields the smallest possible download. Doing both is standard for production.
How to minify CSS
- 1Paste your CSS. Paste the stylesheet or rules you want to compress into the input panel, or load the sample.
- 2Check the result. The CSS is minified as you type. The output panel shows the minified CSS and how many bytes it saves; if the CSS can't be parsed, the line and column of the error are shown with a Go to error button.
- 3Copy the result. Use Copy output, then serve the minified CSS in production and keep the formatted copy for editing.
Examples
Compress a rule
51 bytes → 28 bytes (45% smaller).
Input
.btn {
color: #fff; /* white */
padding: 8px;
}Output
.btn{color:#fff;padding:8px}Shorter colours and numbers
90 bytes → 59 bytes (34% smaller).
Input
.card {
color: #333333;
margin: 0px auto 0px auto;
transition: opacity 0.20s ease;
}Output
.card{color:#333;margin:0 auto;transition:opacity .2s ease}Duplicate rules merged
Input
.a { color: red }
.b { color: red }Output
.a,.b{color:red}Strings and calc() kept
The spaces that matter stay.
Input
.note::before {
content: "a , b";
width: calc(100% + 10px);
}Output
.note:before{content:"a , b";width:calc(100% + 10px)}Licence comment kept
Input
/*! MIT License */
.a { color: red }Output
/*! MIT License */.a{color:red}Unclosed block (error)
Input
.a {
color: redOutput
Line 1, column 1: Unclosed block.
What CSS minification changes
What this minifier removes or shortens, and what it keeps.
| Removed or shortened | Kept exactly |
|---|---|
| Whitespace, line breaks, and comments | Licence comments (/*! … */) |
| The last semicolon in each rule | Text in strings |
| Long colours and numbers (#333333, 0.20s, 0px) | calc() expressions and selectors |
| Exact duplicate rules and empty rules | Vendor prefixes and fallback declarations |
| Separate rules with identical declarations (merged) | Which declaration wins in the cascade |
Frequently asked questions
Does minifying change my styles?
No. The minified CSS applies the same styles to the same elements. Values may be written more briefly (#333333 as #333, 0px as 0) and duplicate rules merged, but strings, selectors, calc() expressions, and nesting keep their meaning, and every change is checked against all browsers with recorded usage.
Why does CSS size matter for performance?
Stylesheets block rendering until they load, so a smaller CSS file lets the browser paint the page sooner, improving load time and Core Web Vitals.
Will it reorder or merge my rules?
Yes, where that's safe. Rules with identical declarations are merged into one selector list and an exact duplicate rule is removed, but only when that can't change which declaration wins in the cascade, and not when some browsers don't understand one of the selectors.
Should I minify custom properties and media queries?
Yes. Custom properties, @media, @supports, @container, @layer, and CSS nesting all minify safely; custom property values are kept apart from extra whitespace.
What happens if my CSS has an error?
The minifier reports the line and column and what's wrong — for example "Unclosed block." or "Unexpected }." — and Go to error moves the cursor there. It doesn't produce output from CSS it can't parse, so you never copy broken CSS by accident.
Is my CSS private?
Yes. Minification runs entirely in your browser, in a background thread. The only exception is the Share link button, which uploads the current output when you click it.
Is it free?
Yes — free and unlimited.
Will minifying break vendor prefixes?
No. Vendor-prefixed properties such as -webkit-backdrop-filter are kept, as are fallback declarations such as display: -webkit-box before display: flex, because every change is checked against all browsers with recorded usage.
Which minifier does it use?
PostCSS parses the CSS and cssnano's default preset (version 8) minifies it — the same tools many build pipelines use. Inline SVG images in url() are left as they are, because re-encoding them usually makes them larger.