Compress CSS to reduce file size or beautify minified CSS for readability. Shows exact savings. Your code never leaves your browser.
CSS minification removes unnecessary characters from your stylesheets without changing functionality. This includes whitespace, comments, unnecessary semicolons, and redundant values. Minified CSS loads faster, reducing page load time and bandwidth.
/* ... */ comments are stripped} is optional0px → 0, 0.5 → .5#ffffff → #fff/* Before (388 bytes) */
.container {
max-width: 1200px;
margin: 0px auto;
padding: 0px 24px;
}
.header {
background-color: #ffffff;
border-bottom: 1px solid #eeeeee;
padding: 16px 0px;
}
/* After (145 bytes — 63% smaller) */
.container{max-width:1200px;margin:0 auto;padding:0 24px}.header{background-color:#fff;border-bottom:1px solid #eee;padding:16px 0}
| CSS File | Original | Minified | Savings |
|---|---|---|---|
| Bootstrap 5.3 | 227 KB | 181 KB | 20% |
| Tailwind CSS | 3.7 MB | 2.9 MB | 22% |
| Hand-written CSS | varies | varies | 30–60% |
<style> tags// PostCSS + cssnano (recommended)
npm install cssnano --save-dev
// postcss.config.js
module.exports = {
plugins: [require('cssnano')({ preset: 'default' })]
}
// Vite (built-in)
// CSS is automatically minified in production builds
// Webpack (css-minimizer-webpack-plugin)
npm install css-minimizer-webpack-plugin --save-dev
CSS minification removes all unnecessary characters from CSS code without changing its functionality — this includes whitespace, line breaks, comments, and sometimes shortening color values and property names. A 100KB CSS file can often be reduced to 60-70KB, improving page load time and Google Core Web Vitals scores.
Minification typically reduces CSS file size by 20-40%. Combined with gzip compression (which servers apply automatically), total savings can be 70-80% compared to uncompressed CSS. Faster CSS delivery means faster render-blocking resource resolution and improved Largest Contentful Paint (LCP) scores.
Yes — always serve minified CSS in production. Tools like webpack, Vite, and Parcel do this automatically during build. For simple projects without a build tool, use an online minifier like this one. Keep the unminified source file for development and serve the minified version to users.
A good CSS minifier never breaks valid CSS. It only removes whitespace and comments, which are ignored by browsers. However, incorrect CSS (like missing semicolons) might parse differently after minification. Always test minified CSS in your target browsers, especially for complex selectors or calc() expressions.
Minification removes unnecessary characters from the source code, making it smaller but still a valid CSS text file. Compression (like gzip or Brotli) is a general-purpose binary compression applied by the server before sending the file. Both work together — minify first, then the server applies gzip for maximum size reduction.