Minify CSS by removing comments and whitespace to reduce file size, or format minified CSS back into readable code. Shows percentage size reduction.
paste CSS to minify or format
Mode
CSS Input
Output (click to copy)
How to Use the CSS Minifier
Paste your CSS — paste formatted CSS code with comments, whitespace, and full property names.
Click Minify — removes all unnecessary whitespace, comments, and redundant code while preserving functionality.
Check size reduction — the tool shows original size, minified size, and percentage reduction achieved.
Copy minified CSS — use in production HTML or save as a .min.css file.
Beautify (reverse) — paste minified CSS and click Beautify to restore readable formatting for editing.
⚡ Size reduction impact: CSS minification typically reduces file size by 20–40%. A 50KB stylesheet becomes 30–40KB. With gzip compression (applied by most web servers), the savings are additional — minified + gzipped CSS can be 80–90% smaller than the original formatted file. Both minification and gzip serve different optimisation purposes and should be used together.
Understanding CSS Minification
📦 What Gets Removed
Comments (/* ... */). Whitespace (spaces, tabs, newlines). Redundant semicolons (last property in rule). Redundant zeros (0.5 → .5, 0px → 0). Long colour names (#ffffff → #fff). Duplicate properties. Empty rules. Vendor prefix duplicates for modern browser targets.
📊 Minification vs Compression
Minification removes redundant characters from source code — reduces file size and removes human readability. Compression (gzip/brotli) applies algorithmic compression to the minified file — further reduces transfer size. These are complementary: minify first, then serve compressed. A 100KB CSS file: after minification ~65KB, after gzip ~15KB.
🔄 Source Maps
Minified code is unreadable for debugging. Source maps link minified code back to original source — browser DevTools shows original formatted CSS when debugging, even when serving minified files. Build tools (webpack, Vite, rollup) generate source maps automatically. Essential for debugging production issues without deploying unminified code.
⚡ Critical CSS
The CSS needed to render above-the-fold content. Inlining critical CSS in the HTML <head> eliminates the render-blocking CSS request, significantly improving First Contentful Paint (FCP). Tools like Critical extract the critical CSS automatically. Minification is especially important for inlined CSS as it goes directly in the HTML.
🏗️ Build Tool Integration
Production CSS minification should be automated in your build pipeline. webpack: css-minimizer-webpack-plugin. Vite: built-in with esbuild. Gulp: gulp-cssnano. PostCSS: cssnano plugin. These tools run automatically on every production build, ensuring minification without manual steps. Manual minification via this tool is useful for quick optimisation or one-off files.
📈 Performance Impact
CSS is render-blocking — the browser cannot display content until all CSS is downloaded and parsed. Smaller CSS files load faster, reducing render-blocking time. On a 3G connection, every 100KB of CSS adds approximately 1–2 seconds of loading time. CSS minification is one of the highest ROI performance optimisations with zero functional impact.
CSS Optimisation Beyond Minification
Removing unused CSS
Most websites ship significantly more CSS than they use. A CSS framework like Bootstrap adds 200KB+ of CSS; most sites use less than 10% of it. Tools like PurgeCSS, UnCSS, and Tailwind CSS's purge mode analyse HTML and remove unused CSS selectors. Combined with minification, this can reduce a 200KB framework CSS file to under 10KB — a 95% reduction. Removing unused CSS provides dramatically larger savings than minification alone.
CSS architecture for performance
CSS performance starts at the architecture level. Avoid deeply nested selectors (.nav > ul > li > a > span) — each level adds matching complexity. Use specific class selectors rather than element selectors for frequently-applied styles. Avoid universal selectors (*) in performance-critical contexts. Group and reuse common properties through utility classes (as Tailwind CSS does) to reduce total CSS size. Well-architected CSS is smaller before minification, not just after.
HTTP/2 and CSS file splitting
HTTP/1.1 required bundling all CSS into one file to minimise requests. HTTP/2 (used by most modern servers including Cloudflare) supports multiplexed requests — multiple files load simultaneously without overhead. This enables splitting CSS into logical chunks: critical CSS (inline), above-fold CSS (immediate load), and below-fold CSS (deferred). This approach can improve Time to First Contentful Paint even compared to a single minified CSS file.
⚡ CSS performance checklist: Minify all CSS ✓. Enable gzip/brotli on server ✓. Remove unused CSS (PurgeCSS) ✓. Inline critical CSS ✓. Defer non-critical CSS loading ✓. Use CDN for CSS delivery ✓. Set long cache headers for versioned CSS files ✓. These seven steps together can reduce CSS-related page load time by 70–90% on typical websites.
Frequently Asked Questions
Why minify CSS?
Minified CSS loads faster because it's smaller — removing whitespace, comments, and redundant characters reduces file size by 20–50%. Every kilobyte saved improves page load speed, which affects both user experience and Google rankings.
Does minification change how CSS works?
No. Minification only removes characters that the browser ignores anyway — whitespace (spaces, newlines, tabs) and comments. The visual output of minified CSS is identical to the original.
When should I format CSS?
Format CSS when you receive minified code and need to read or edit it, when reviewing CSS from a third-party library, or when you want to standardise indentation in a project. Formatted CSS is human-readable but not suitable for production.
Should I minify CSS in development?
No — keep readable CSS during development. Minify only for production. Most build tools (Webpack, Vite, Parcel) handle minification automatically as part of the build process. Manual minification is useful for quick testing or simple projects without build tools.