CSS Minifier
MinifiersCompress CSS to minimum size — remove whitespace, comments, shorten values. Free, private — all processing in your browser.
The CSS Minifier compresses CSS files by 60-80% without changing their behavior. Removes all unnecessary whitespace (spaces, tabs, newlines), strips comments, shortens color codes (#ff0000 → #f00), omits trailing zeros (0.5 → .5), removes default values where safe, and more. The output is byte-identical in effect to your source CSS — just dramatically smaller. Essential for production deploys: smaller CSS = faster page loads = better Core Web Vitals = better SEO.
CSS is typically 5-10% of a page's total bytes but loaded synchronously — it blocks rendering. A 100KB CSS bundle minified to 25KB saves 75KB on every page load. Across thousands of visitors, that is significant bandwidth. Combined with gzip/brotli compression, the HTTP wire transfer can be 90%+ smaller than source. Modern build tools (Webpack, Vite, Rollup) minify automatically, but this tool is perfect for ad-hoc minification — single files, third-party CSS before inclusion, email templates, or any CSS outside a build pipeline.
CSS Minifier — key features
Maximum compression
Multiple optimizations combined: whitespace, comments, value shortening, unit removal. 60-80% reduction typical.
Safe optimizations
Does not change CSS behavior. Only removes unnecessary characters and applies equivalent shortforms.
Color code shortening
#ffffff → #fff, rgb(255,255,255) → #fff. Small per-occurrence but adds up across a codebase.
Zero value optimization
0px → 0, 0.5 → .5. Unit-less zeros are valid and save characters.
Comment preservation option
Keep license/copyright comments (/*! */) while removing other comments.
Before/after stats
Shows original size, minified size, and savings percentage. Know exactly what you gain.
Handles large files
Multi-megabyte CSS minifies without issue in-browser.
100% client-side
Your CSS (possibly containing design system details) stays in browser.
How to use the CSS Minifier
- 1
Paste your CSS
Source CSS — formatted, commented, indented. Can be from a single file or bundled output.
- 2
Configure options
Preserve license comments? Aggressive value shortening? Most defaults work well.
- 3
Click Minify
Minified CSS appears instantly with size comparison.
- 4
Review size savings
Typical: 60-80% smaller. Verify the savings match your expectation.
- 5
Copy or download
Copy to clipboard or download as .min.css file. Ready for production.
Common use cases for the CSS Minifier
Production optimization
- →Manual deploy: No build pipeline? Minify CSS before uploading to your server or CDN.
- →Static sites: Hand-built static sites — minify CSS in the build step.
- →CMS themes: WordPress, Drupal custom themes — minify for production performance.
- →Email templates: HTML emails with inline CSS — minify to reduce attachment size and improve client rendering.
Performance
- →Core Web Vitals improvement: Smaller CSS = faster LCP (Largest Contentful Paint). Google ranking factor.
- →Mobile optimization: Smaller CSS loads faster on 3G/4G connections. Significant improvement on slow networks.
- →CDN cost reduction: Smaller files = less bandwidth billed. Minification + gzip can reduce CDN costs 5-10x.
- →Critical CSS: Above-the-fold CSS inlined in HTML. Minified is essential to not bloat HTML.
Special cases
- →Third-party CSS: Libraries that distribute unminified CSS. Minify before bundling.
- →Generated CSS: CSS generated by tools (Tailwind, CSS-in-JS extraction). Often not minified by default.
- →Legacy codebases: Projects without modern build pipelines — manually minify.
- →Microsites: One-off landing pages with hand-written CSS.
CSS Minifier — examples
Basic minification
Typical CSS file.
/* Button styles */
.btn {
background: #3498db;
color: #ffffff;
padding: 10px 20px;
border-radius: 4px;
}
.btn:hover {
background: #2980b9;
}.btn{background:#3498db;color:#fff;padding:10px 20px;border-radius:4px}.btn:hover{background:#2980b9}
Size: 180 bytes → 96 bytes (47% smaller)Complex selectors
Media queries preserved.
@media (max-width: 768px) {
.sidebar {
display: none;
}
.main {
width: 100%;
}
}@media (max-width:768px){.sidebar{display:none}.main{width:100%}}Color optimizations
#ffffff becomes #fff, rgb becomes hex.
.a { color: #ffffff; }
.b { color: rgb(255, 0, 0); }
.c { color: rgb(255, 255, 255); }.a{color:#fff}.b{color:#f00}.c{color:#fff}Zero value shortening
Units removed for zero, leading zero removed.
.x {
margin: 0px 0.5em 0px 1.5em;
padding: 0;
opacity: 0.75;
}.x{margin:0 .5em 0 1.5em;padding:0;opacity:.75}License comment preserved
/*! */ comments kept.
/*! MIT License - Copyright 2026 */
.btn { color: blue; }
/* Regular comment */
.btn:hover { color: red; }/*! MIT License - Copyright 2026 */.btn{color:blue}.btn:hover{color:red}Real-world file
Typical blog CSS.
50KB CSS file with ~300 rules
14KB minified (72% reduction) After gzip: 4KB (92% total reduction)
Technical details
CSS minification applies multiple optimizations. Typical reduction: 60-80% of source size.
Whitespace removal:
- Space between selectors and braces: .class { color: red; } → .class{color:red}
- Newlines between declarations.
- Indentation.
- Blank lines.
Comment removal:
- /* comments */ removed (except special /*! preserved */ comments used for licenses).
Value shortening:
Colors:
- #ffffff → #fff
- rgb(255, 255, 255) → #fff (if opaque)
- black → #000
- white → #fff
Zero values:
- 0px, 0em, 0% → 0 (units dropped when value is 0)
- 0.5 → .5
- 0.0 → 0
Margin/padding shorthand:
- margin: 10px 10px 10px 10px → margin: 10px
- margin: 10px 20px 10px 20px → margin: 10px 20px
Double quotes vs single quotes:
- url("image.png") → url(image.png) (when no special chars)
- "Arial" vs 'Arial' — shortened based on context
Semicolon optimization:
- Last declaration in a rule can omit semicolon: color: red} instead of color: red;}
Empty rule removal:
- .unused {} — empty rule removed (provided it has no pseudo-elements with content)
What is preserved:
- All CSS behavior unchanged.
- Vendor prefixes preserved.
- !important flags.
- Important comments with /*! */.
- Custom properties (--var-name).
- Media queries, container queries, supports queries.
Advanced optimizations (not always applied):
- Duplicate rule merging: two identical rules combined. Risky — may change specificity.
- Unused rule removal: requires knowing which rules are actually used (PurgeCSS territory).
- Property shorthand combining: separate properties merged into shorthand.
These optimizations can change specificity or remove useful rules. This minifier applies only safe optimizations.
Combined with gzip/brotli:
Minification + compression:
- Source: 100KB
- Minified: 30KB (70% reduction from source)
- Gzipped: 8KB (97% reduction from source)
Most HTTP servers auto-apply gzip/brotli. Minification helps before compression kicks in.
When to minify:
- Production: always. Ship minified CSS.
- Development: no. Debug with source CSS.
- Build tools handle this: Webpack, Vite, Rollup, esbuild all minify in production mode.
Modern build tools do this better:
Production build pipelines (PostCSS + cssnano, esbuild) do more aggressive minification than browser tools — dead code elimination, tree shaking. For new projects, use a build tool. This standalone minifier is for ad-hoc or legacy cases.
Common problems and solutions
⚠Some minifiers over-optimize
Advanced optimizations (duplicate rule merging, property combining) can change CSS specificity or behavior. This tool applies only safe optimizations. Aggressive tools like cssnano have optional risky optimizations.
⚠Comments with functional role removed
/* autoprefixer: on */ and similar directives can be removed. Use /*! important comments */ syntax to preserve them. Or configure minifier to preserve specific patterns.
⚠Vendor prefixes look odd
Prefixes like -webkit-flex are preserved. Some minifiers drop redundant prefixes (if modern alternative exists) — this tool keeps all.
⚠Minified CSS breaks selectors
Rare but possible — some parsers are strict about whitespace in attribute selectors like `[href="x"]`. If minified version breaks, check attribute values with spaces.
⚠Debugging minified CSS
Minified CSS is hard to debug. For development, use source CSS. For production, serve minified but include source maps for debugging.
⚠Already minified input
Minifying already-minified CSS does little extra — already compact. No harm done, just no savings.
⚠Custom at-rules
Modern CSS has @container, @layer, @supports. Minifier preserves these. If you see rules disappear, your minifier is outdated.
⚠Relative URL issues
url(../images/pic.png) is preserved. If CSS is moved to a different directory, relative URLs break. Minification does not change URLs, but relocation does.
CSS Minifier — comparisons and alternatives
CSS Minifier vs CSS Formatter: Minifier compresses for production. Formatter expands for readability. Opposite operations; lossless roundtrip. See our CSS Formatter.
This tool vs cssnano: cssnano is an advanced PostCSS-based minifier with many optimization levels and plugins. More aggressive, more configurable. This tool is simpler and runs in browser.
This tool vs clean-css: clean-css is a popular Node.js minifier. Runs on server/CLI. Similar optimization capabilities.
Minification vs gzip compression: Both reduce file size but differently. Minification removes unnecessary characters. Gzip compresses the resulting bytes. Use both — minify at build time, gzip at HTTP layer.
Minification vs critical CSS extraction: Minification reduces file size. Critical CSS identifies which CSS is needed for above-the-fold rendering. Both optimize for Core Web Vitals; complementary not competing.
Manual minification vs build tools: Modern build pipelines (Vite, Webpack) minify automatically in production. This tool is for ad-hoc minification of individual files, legacy projects, or standalone CSS files. For new projects, use build tool minification.
Frequently asked questions about the CSS Minifier
▶What does CSS minification do?
Removes all unnecessary characters from CSS without changing behavior. Strips whitespace, comments, shortens color codes, removes unnecessary zeros. Typical result: 60-80% smaller file. Output is functionally identical to input — just more compact.
▶Is minification lossless?
Yes. CSS behavior is preserved exactly. A browser applies minified and formatted CSS identically. You can un-minify (format) minified CSS to get clean code back.
▶How much can I save by minifying?
60-80% typically. Heavily-commented CSS with lots of whitespace saves more. Minimal CSS (already concise) saves less. Combined with gzip compression, HTTP transfer is typically 90-95% smaller than source.
▶When should I minify?
For production deploys. Not for development (hard to debug). Modern build tools (Webpack, Vite) minify automatically in production mode. Use this tool for ad-hoc minification when no build pipeline.
▶Is my CSS safe to paste here?
Yes. Minification happens entirely in your browser. CSS never uploads. Safe for proprietary design system code, internal CSS, client work.
▶Should I also use gzip?
Yes, if your server supports it (virtually all do). Minification + gzip = maximum savings. HTTP auto-negotiates gzip/brotli via Accept-Encoding. Configure your server to enable.
▶What about source maps?
For production debugging, generate source maps during build. Source map (.map file) links minified CSS back to original for browser dev tools. This simple minifier does not generate maps — use build tools for that.
▶Does it preserve my vendor prefixes?
Yes. -webkit-, -moz-, -ms- prefixes preserved. Some advanced minifiers can drop redundant prefixes (if modern alternative exists). This tool keeps all original.
▶Can I reverse the minification?
Yes. Run minified CSS through our CSS Formatter. You will get readable CSS, though comments that were stripped are lost forever.
▶Why is my CSS not shrinking much?
Possible reasons: (1) Already minified (just slight extra savings). (2) Long content in values (long URL paths, background images) do not shrink. (3) Limited whitespace in source — less to remove. Check file size stats the tool provides.
Additional resources
- cssnano — Advanced PostCSS-based CSS minifier.
- clean-css — Node.js CSS minifier library.
- CSS Optimization (web.dev) — Google best practices for CSS performance.
- HTTP Compression (MDN) — gzip and brotli for HTTP responses.
- Critical CSS — Extracting above-the-fold CSS for faster rendering.
Related tools
All MinifiersCSS Box Shadow Generator
Create realistic CSS box shadows — single, layered, inset, neumorphism styles
CSS Flexbox Playground
Build flex layouts interactively — see changes live, copy production CSS
CSS Formatter
Beautify and indent CSS, SCSS, LESS code — configurable style, production-ready output
CSS Gradient Generator
Create linear, radial, and conic CSS gradients with live preview
CSS Grid Generator
Design CSS Grid layouts visually — define rows, columns, areas, copy code
CSS Unit Converter
Convert between CSS units — px, rem, em, vw, vh, %, pt, cm — for responsive design
Learn more
Explore more tools
200+ free tools that run in your browser.
Browse all tools →