CSS Minifier
Compress your CSS code instantly — remove comments, collapse whitespace, shorten hex colors, and shrink file size by up to 80%. Free, fast, and 100% browser-based — your code never leaves your machine.
How to Use the CSS Minifier
- Paste your CSS — Copy your CSS source code and paste it into the input
area above. You can also upload a
.cssfile or drag & drop it directly. - Choose a preset — Select Safe for zero-risk minification, Aggressive for the best balance (recommended), or Maximum to enable all optimizations. Or click "Advanced Options" to control each setting individually.
- Click "Minify CSS" — The tool instantly processes your code and shows the minified result with before/after size comparison and a breakdown of what was removed.
- Copy or Download — Click "Copy" to copy the minified CSS to your
clipboard, or "Download .css" to save it as
styles.min.cssfor deployment.
Beautify mode: Switch to the Beautify tab to format minified or poorly-indented CSS into clean, readable code with your preferred indentation — 2 spaces, 4 spaces, or tabs.
About Our Free CSS Minifier
CSS files are one of the most impactful assets to optimize for web performance. Every CSS file must be fully downloaded and parsed before the browser can render your page — a process known as render-blocking. Minifying your CSS directly reduces this blocking time, improving First Contentful Paint (FCP) and Largest Contentful Paint (LCP) — two of Google's Core Web Vitals ranking signals.
Our CSS Minifier is a best-in-class, free online tool that offers 10 granular optimization options with full control over what gets compressed:
- Comment removal — Strips
/* ... */comments, with an option to preserve/*! ... */important license headers - Whitespace collapsing — Removes all unnecessary spaces, tabs, and
newlines, plus whitespace around
{ } : ; ,operators - Last semicolon removal — Removes the trailing semicolon before
}, which is always safe per the CSS specification - Zero unit removal — Converts
0px,0em,0rem,0%to bare0— time units (0s,0ms) are never touched - Leading zero removal —
0.5becomes.5,-0.75becomes-.75 - Hex color shortening —
#ffffff→#fff,#aabbcc→#abc - Empty rule removal — Deletes
.class { }blocks with no declarations - Shorthand compression —
margin: 10px 10px 10px 10px→margin: 10px - Vendor prefix removal — Safely removes outdated
-webkit-,-moz-,-o-,-ms-prefixes for properties now universally supported without them - Protected tokens —
url(),calc(),var(),min(),max(),clamp(), and quoted strings are never modified — spaces insidecalc()are required by spec and always preserved
100% browser-based — your CSS code is never uploaded to any server. All processing runs entirely in your browser using JavaScript. No file size limits, no signup, no privacy concerns.
Why Choose Our CSS Minifier Over Others?
- calc() and url() are protected — Most basic online minifiers corrupt
background: url("path with spaces")or breakcalc(100% - 20px)by removing the required spaces. Our tool automatically detects and protects all math functions and URL tokens before processing. - 0s / 0ms time units are safe —
transition: all 0sandanimation-duration: 0msare valid CSS. Our zero-unit removal only targets length and size values (px, em, rem, %) — never time or angle units. - CSS variable (custom property) safe —
--custom-property: 0pxvalues andvar()expressions are fully protected throughout the minification pipeline. - Built-in Beautifier — Toggle to Beautify mode to format any minified CSS with your preferred indent style. Most competitor tools offer this as a separate page; ours is one click away.
- What was removed summary — After every minification, see exactly how many comments, whitespace characters, zero units, hex colors, and empty rules were removed. Not just a percentage — a full audit trail.
- 3 presets + 10 individual options — Start with Safe, Aggressive, or Maximum presets, then fine-tune any individual setting. Most tools offer all-or-nothing; ours gives you surgical control.
- Draft persistence — Your last CSS input is saved in localStorage and restored automatically when you return to the page. Never lose work-in-progress.
When Should You Minify CSS?
- Before deploying to production — Always serve minified CSS on live sites. The performance gains are immediate: smaller files download faster, parse faster, and reduce render-blocking time for every user visit.
- Optimizing WordPress themes — WordPress themes often have heavily
commented
style.cssfiles. Minifying them can reduce size by 40–60%. Use the Safe preset and test your site visually after replacing the file. - After building custom CSS frameworks — When generating a custom Bootstrap or Tailwind build, run it through the minifier before including it in your project.
- Email CSS optimization — HTML email clients have strict size limits. Minifying your email's inline CSS reduces the total message size and avoids Gmail's clipping threshold.
- React / Vue / Angular CSS-in-JS — Component CSS files and CSS modules benefit from minification, especially for large design system codebases.
- Improving Core Web Vitals scores — If your Lighthouse report shows "Eliminate render-blocking resources" or "Reduce unused CSS", minification is the first and easiest fix. Combine with GZIP on your server for maximum impact.
Pro tip: For best results, combine CSS minification with GZIP/Brotli compression on your server and proper Cache-Control headers for your CSS files. Use our .htaccess Generator to add compression and caching rules automatically.
Frequently Asked Questions
What is CSS minification and why does it matter?
Will minifying CSS break my website's styles?
url(), calc(), and quoted strings are never modified.
Use the Safe preset for zero-risk minification — it only removes comments
and collapses whitespace. Always use the Restore button or keep a backup of your original
CSS file.
How much file size reduction can I expect?
What's the difference between CSS minification and GZIP compression?
Should I minify CSS in production?
How do I minify CSS in WordPress?
style.css content into this tool,
download the minified result, and replace the file on your server. Keep a backup of the
original. The manual approach is ideal for child themes, custom page builder CSS, or
specific stylesheets you want to control individually.
Can I minify CSS with CSS variables (custom properties)?
--primary-color: #0070E0 and
color: var(--primary-color) are completely safe. The var()
function is automatically protected — whitespace inside var() expressions is
preserved exactly. Zero-unit removal only targets length properties (px, em, rem, %) and
never custom property names or values, so --spacing: 0px would still correctly
become --spacing: 0 if you enable that option.
What are /*! important comments and should I preserve them?
/*! ... */) are a widely-used CSS convention for marking
license headers, copyright notices, and file metadata that should remain visible even in
minified output. For example, Bootstrap and Font Awesome include /*! comments
at the top of their CSS files. Enable the "Keep /*! important comments"
option in this tool to preserve these while stripping all regular comments.
Is it safe to remove vendor prefixes like -webkit- and -moz-?
border-radius,
box-shadow, transform, transition, and
animation are all universally supported without any vendor prefix in Chrome,
Firefox, Safari, and Edge. Our tool only removes these specific safe-to-remove prefixes.
For cutting-edge CSS features that still require prefixes (like some WebKit-only properties),
leave the vendor prefix option off. When in doubt, test in your target browsers before deploying.
Why does calc() need spaces? Will minifying break it?
+ and -
operators inside calc(). Without spaces, the parser fails:
calc(100% - 20px) is valid, but calc(100%-20px) is invalid.
Our minifier automatically detects and fully protects all calc(),
min(), max(), and clamp() expressions — the
internal spaces are never removed. This is one of the most common failure modes in basic
online minifiers.