CSS Minifier
Minify CSS online. Remove comments, whitespace, and redundant characters to reduce file size.
Paste CSS and click Minify to strip whitespace, comments, and unnecessary semicolons. Reduces file size by 20 to 60% for faster page loads.
Use it for one-off CSS snippets, email styles, or static pages when you do not have a build pipeline.
Input CSS
Minified Output
Why Minify CSS?
CSS files are render-blocking, the browser won't paint anything until it's downloaded and parsed your stylesheets. Every kilobyte of CSS directly delays your First Contentful Paint (FCP). Minification removes the parts humans need (comments, indentation, whitespace) while keeping everything the browser needs.
A typical stylesheet shrinks 20-40% after minification. Combined with Gzip/Brotli compression, a 100 KB CSS file can drop to under 15 KB over the wire. Smaller blocking CSS helps the first render start sooner and can improve Core Web Vitals.
What Minification Removes
| Element | Before | After | Safe? |
|---|---|---|---|
| Comments | /* Header styles */ | (removed) | Always safe |
| Indentation | margin: 0; | margin:0 | Always safe |
| Selector spacing | .btn > span { } | .btn>span{} | Always safe |
| Last semicolons | color: red; } | color:red} | Always safe |
| Line breaks | Multiple lines per rule | One continuous line | Always safe |
The minified CSS renders identically for standard rules. Always keep your source files readable and only minify for production output.
Real Size Savings
Here's what minification looks like on real-world stylesheets:
| Stylesheet | Original | Minified | Savings |
|---|---|---|---|
| Small site (50 rules) | 8 KB | 5 KB | 37% |
| Medium site (200 rules) | 35 KB | 24 KB | 31% |
| Bootstrap 5 | 230 KB | 190 KB | 17% |
| Tailwind (purged) | 50 KB | 38 KB | 24% |
After Gzip, the minified files compress even further, typically 70-85% smaller. Minification + compression is the standard production pipeline.
Build Tool Comparison
For production projects, build tools do more than basic minification. Here's how they compare:
This tool (online)
Quick one-off minification. No setup needed. Paste CSS, get minified output. Ideal for snippets, debugging, or when you're not near your build environment.
cssnano / PostCSS
Production standard. Advanced optimisations: shorthand merging, colour reduction, calc() simplification. Integrates with Webpack, Vite, Rollup.
Lightning CSS
Rust-based and quick in build pipelines. Handles minification, vendor prefixing, and CSS nesting in one pass. Often used in newer frontend projects.
PurgeCSS / Tailwind JIT
Removes unused CSS entirely, not just whitespace but whole rules. The biggest wins come from tree-shaking, not minification.
Worked Example: Minifying a Static Landing Page
Priya has a single-page product microsite with a 34 KB hand-written stylesheet. There is no build step because the page is uploaded as plain HTML, CSS, and images.
1. Keep the source file
She keeps styles.css readable with comments and indentation. That is the file she edits later.
2. Create a deploy copy
She pastes the readable CSS into the minifier and downloads styles.min.css.
3. Update the HTML link
The page links to the minified file for production. The source file remains in the project folder as the editable copy.
4. Test the result
She reloads the page, checks buttons, forms, and responsive breakpoints, then uploads the minified file with the rest of the site.
When Minification Is Not Enough
Minification trims characters from rules you already have. It does not decide whether those rules are still needed. Large sites often need several CSS-size tactics working together.
| Problem | Minification helps? | Better next step |
|---|---|---|
| Too much whitespace and comments | Yes | Minify the production copy |
| Unused framework classes | Only slightly | Purge unused selectors in your build step |
| Large icon font CSS | Only slightly | Subset the font or switch to inline SVG icons |
| Critical CSS blocking render | Somewhat | Inline critical CSS and defer the rest |
| No server compression | Somewhat | Enable gzip or brotli on the server or CDN |
CSS Minification Edge Cases
Data URLs
CSS can contain embedded SVG or font data. A cautious minifier should not rewrite the contents of a data URL unless it understands that format.
calc() spacing
CSS requires spaces around + and - inside calc(). This tool preserves those spaces. If you use another minifier, verify your calc() expressions still work after minification.
Custom properties
Values inside CSS variables can be intentionally flexible. Some build minifiers avoid aggressive rewriting there because the variable may be used in several contexts.
Source maps
A production build can generate a source map so DevTools points back to your readable file. This one-off minifier produces only the CSS, not a source map.
Safe Minification Checklist
- Minify a copy. Keep the readable source file in your project and deploy the minified output separately.
- Test responsive breakpoints. Minification should not change CSS behaviour, but testing catches pasted input mistakes.
- Check the file link. If you download
styles.min.css, make sure the HTML points to that exact filename. - Enable compression too. Minification and gzip or brotli work together. One does not replace the other.
- Avoid minifying broken CSS. If the browser already ignores part of the file, minifying it will not fix the syntax error.
Related Tools
How to use this tool
Paste your CSS into the input area
Click Minify CSS to compress
Copy the result or download as styles.min.css
Common uses
- Reducing CSS file size for production deployment
- Stripping comments before going live
- Preparing inline CSS for HTML email templates
- Quick minification for small CSS snippets
Share this tool
Frequently Asked Questions
What does CSS minification do?
Will minification break my styles?
Is my CSS sent to a server?
How much will my file shrink?
Should I minify CSS during development?
What's the difference between minification and compression?
Does this remove unused CSS selectors?
Should I keep a readable copy of the original CSS?
Can I minify CSS for HTML email?
Does minification change CSS specificity?
Can I minify CSS variables?
Why keep comments out of production CSS?
Can I paste only part of a CSS file?
Results are for general informational purposes only and should be checked before use. They are not professional advice. See our Disclaimer and Terms of Service.