CSS Minifier
Remove whitespace and comments from CSS.
Example
- In:
- .btn { color: red; padding: 8px; }
- Out:
- .btn{color:red;padding:8px}
Paste or type text, then click Minify.
Guide
Introduction
CSS files grow until every unused rule, comment, and whitespace byte ships to every visitor. A design system stylesheet hits 200 KB unminified. A critical-path inline style block delays first contentful paint. Build pipelines minify automatically — but when you're prototyping in CodePen, patching a WordPress theme, or debugging a third-party snippet, you need compression without spinning up PostCSS locally.
Certoflow's CSS Minifier strips comments, collapses whitespace, and removes unnecessary semicolons entirely in your browser. Paste a stylesheet, click Minify, copy the one-line or compact output. No upload to remote build servers — your unreleased brand tokens, A/B test selectors, and internal class naming stay on your machine.
What this tool does
The minifier reduces CSS file size while preserving cascade semantics:
| Operation | Effect |
|---|---|
| Remove comments | Strips /* ... */ blocks including license headers unless configured to preserve |
| Collapse whitespace | Removes spaces, tabs, newlines between tokens where safe |
| Optimize zeros | 0px → 0, #ffffff → #fff where applicable |
| Merge rules | Some minifiers combine identical selectors (implementation-dependent) |
| Copy output | One-click export to clipboard |
Invalid CSS may minify with unpredictable results or surface parse warnings. Fix syntax errors in development sources before minifying for production embed.
How it works
Client-side CSS minification parses the stylesheet into a token stream or AST (abstract syntax tree), then emits compact serialization:
/* Input */
.header {
margin-top: 0px;
padding: 16px 24px;
background-color: #ffffff;
}
.nav-item {
display: flex;
gap: 8px;
}
/* Minified output */
.header{margin-top:0;padding:16px 24px;background-color:#fff}.nav-item{display:flex;gap:8px}
Processing uses in-browser JavaScript — no fetch to CDN optimization APIs. Typical stylesheets minify in milliseconds.
What minification preserves vs removes
| Preserved | Often removed or shortened |
|---|---|
| Selector specificity order | Comments |
@media query breakpoints | Extra semicolons before } |
Custom property (--var) names | Insignificant whitespace |
url() references | Leading zeros in units |
@keyframes step order | Duplicate spaces |
Minification is not prefixing. Vendor prefixes (-webkit-) remain unless you use Autoprefixer separately. Minification is not tree-shaking — unused rules stay unless you purge with PurgeCSS or similar upstream.
Real-world examples
Inline critical CSS in HTML
Above-the-fold styles embed in <style> tags. Minifying 4 KB of critical CSS saves transfer on every HTML document request — multiplied across millions of page views.
<style>.hero{min-height:60vh;display:grid;place-items:center}</style>
Email template size limits
Some email clients choke on messages exceeding size thresholds. Minify embedded <style> blocks after final QA on formatted CSS.
Third-party widget override
You inject 30 lines overriding a SaaS widget's z-index and colors. Minify before adding to a tag manager snippet with character limits.
Quick size comparison in design reviews
Designers ask whether a new component's CSS justifies its weight. Minify the component stylesheet and compare byte count against budget (e.g., 5 KB gzipped).
Prototyping without a build step
Static HTML demos on internal servers lack webpack. Minify manually before sharing with stakeholders who view source.
Verifying copy-paste from DevTools
Copied computed styles from Chrome sometimes include invalid shorthand. Minify to confirm the pasted block parses — errors indicate cleanup needed.
Common mistakes
Minifying invalid CSS. Unclosed braces or malformed @import order produces broken output. Validate in a linter first.
Minifying then editing by hand. One-line CSS is error-prone. Keep formatted source in version control; minify in CI for artifacts.
Removing license comments required by dependencies. Some open-source fonts and libraries mandate retaining copyright headers. Configure preservation or keep licenses elsewhere.
Assuming minification replaces gzip. Always enable Brotli or gzip at the CDN. Minification reduces plaintext entropy slightly; compression still dominates savings.
Breaking CSS that relies on hack comments. Legacy IE hacks using \9 or comment triggers may interact badly with aggressive comment stripping — test on target browsers if you still support them.
Minifying CSS with unprocessed @import chains. @import inside minified files still causes sequential requests. Bundle imports at build time for production.
Expecting automatic prefix removal. Outdated -webkit-border-radius stays unless you run a prefix optimizer. Minifiers do not modernize syntax.
Use cases
Frontend developers compressing critical CSS, CodePen exports, and emergency hotfix styles.
WordPress theme authors minifying style.css fragments before deployment on hosts without Node build tooling.
Email developers reducing payload size in responsive templates tested across Outlook and Gmail.
Performance engineers estimating stylesheet weight contribution before authorizing new UI libraries.
Students learning which CSS syntax is optional (semicolons before closing braces) by comparing formatted vs minified output.
DevOps teams validating minified CSS artifacts in CI match source when build reproducibility is audited.
FAQ
Is my CSS sent to a server?
No. Minification runs entirely in your browser.
Does minification change how styles apply?
Correct minification preserves computed styles. Order, specificity, and @media logic remain equivalent for valid CSS.
Can I minify SCSS or LESS?
No. Compile to CSS first, then minify plain CSS output.
Will my custom properties (--color-primary) survive?
Yes. Variable names and values remain; only whitespace and comments around them shrink.
How much size reduction should I expect?
Often 20–40% for commented, indented stylesheets. Already-compact CSS sees smaller gains. gzip compresses both, but minified input gzips slightly better.
Does the tool merge duplicate selectors?
Depends on implementation. Do not rely on merging for deduplication — use structured refactoring.
Can I minify @keyframes animations?
Yes. Keyframe steps and percentages remain; whitespace between them collapses.
What about calc() and clamp() expressions?
Whitespace inside function arguments is often optional but sometimes significant. Quality minifiers preserve required spaces in calc(100% - 20px).
Is there a file size limit?
Browser memory applies. Split large design system dumps into component chunks for in-browser minification.
Can I use this offline?
Yes, after initial page load.
Frequently Asked Questions
- Is this as advanced as build-tool minifiers?
- It performs safe whitespace and comment removal. For advanced optimizations, use PostCSS or cssnano in your build pipeline.
- Does it break CSS?
- It preserves strings and avoids changing selectors. Always test minified output in your project.
Related Tools
Continue with these related utilities.
JavaScript Minifier
Compress JavaScript snippets locally.
Developer ToolsHTML Formatter
Indent and format HTML markup.
Developer ToolsJSON Minifier
Compress JSON to a single line.
Developer ToolsBase64 Encode
Encode text to Base64 with UTF-8 support.
Developer ToolsHex Converter
Convert text, hex, and decimal in both directions.