Skip to main content

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.

0 chars | 0 lines
Quick preset:

Ctrl + Enter to run

How to Use the CSS Minifier

  1. Paste your CSS — Copy your CSS source code and paste it into the input area above. You can also upload a .css file or drag & drop it directly.
  2. 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.
  3. 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.
  4. Copy or Download — Click "Copy" to copy the minified CSS to your clipboard, or "Download .css" to save it as styles.min.css for 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 bare 0 — time units (0s, 0ms) are never touched
  • Leading zero removal0.5 becomes .5, -0.75 becomes -.75
  • Hex color shortening#ffffff#fff, #aabbcc#abc
  • Empty rule removal — Deletes .class { } blocks with no declarations
  • Shorthand compressionmargin: 10px 10px 10px 10pxmargin: 10px
  • Vendor prefix removal — Safely removes outdated -webkit-, -moz-, -o-, -ms- prefixes for properties now universally supported without them
  • Protected tokensurl(), calc(), var(), min(), max(), clamp(), and quoted strings are never modified — spaces inside calc() 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 break calc(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 safetransition: all 0s and animation-duration: 0ms are 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: 0px values and var() 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.css files. 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?
CSS minification removes unnecessary characters from CSS code — whitespace, comments, and redundant values — without changing how the styles work. This reduces file size, speeds up page load, and directly improves Core Web Vitals scores (FCP and LCP) which Google uses as ranking signals. Smaller CSS files take less time to download, parse, and apply — directly reducing render-blocking time.
Will minifying CSS break my website's styles?
No — when done correctly. Our minifier only removes characters that are truly unnecessary. It never reorders declarations, changes property values, or alters the cascade. Protected tokens like 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?
Typical savings range from 20% to 80%, depending on how your CSS is written. Well-formatted CSS with lots of comments and whitespace (like a default Bootstrap build) can see 50–70% reduction. Compact utility CSS with minimal formatting might see 15–25%. The compression bar and "what was removed" summary after each run shows your exact savings.
What's the difference between CSS minification and GZIP compression?
They work at different levels and complement each other. CSS minification permanently removes redundant characters from the file — the size reduction is baked in before the file ever reaches the server. GZIP compression is applied at the server level during transmission — the browser decompresses the file on arrival. For best results, do both: minify first, then enable GZIP on your server (use our .htaccess Generator). Minified CSS also compresses better with GZIP since there is less repetitive whitespace to encode.
Should I minify CSS in production?
Yes — always. Minified CSS is standard practice for all production websites. Keep your original, readable CSS files for development (for debugging and future edits), then use the minified version on your live site. If you use a build tool like Webpack, Vite, Parcel, or Gulp, CSS minification is typically built in via plugins. For manual workflows or simple static sites, this tool handles it in one click.
How do I minify CSS in WordPress?
You have two options. Automated (recommended): Use a caching plugin like WP Rocket, Autoptimize, or LiteSpeed Cache — all include CSS minification and concatenation as toggles in their settings. Manual: Paste your theme's 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)?
Yes, fully. CSS custom properties like --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?
Important comments (/*! ... */) 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-?
For modern browser targets — yes, for specific properties. 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?
The CSS specification requires spaces around the + 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.
What is CSS beautify and when would I use it?
CSS beautify (also called CSS formatting or prettifying) reformats minified or messy CSS into clean, properly-indented, readable code. Use it when: you receive a minified CSS file from a vendor and need to read or edit it; you're debugging someone else's code; or you want to standardize indentation across a team's codebase. Switch to Beautify mode in this tool — choose your indent style (2 spaces, 4 spaces, or tab) and optionally sort properties alphabetically.
Is my CSS code stored anywhere? Is this tool safe?
Completely safe. All processing happens 100% in your browser using client-side JavaScript. Your CSS code is never uploaded to any server, never logged, and never stored anywhere except optionally in your own browser's localStorage as a draft (which you can clear at any time by clicking the Clear button). Close the tab and it's gone.

Need a Blazing-Fast, SEO-Optimized Website?

Our development team builds performance-first websites that score 90+ on Lighthouse, rank on Google, and convert visitors into customers.

Talk to an Expert