Loading CSS Minifier...
Please wait a moment

How to Minify CSS Code - Step by Step Guide

Step 1

Input Your CSS Code

Ready to optimize your CSS? Simply paste your CSS code into the input area. The minifier removes the comments and the whitespace the browser does not need, which is the cheapest win in making CSS load faster.

Example: Try This CSS Code

Copy and paste this CSS example to see how it works:

/* Navigation Styles */
.navbar {
  background-color: #2c3e50;
  padding: 1rem 2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Button Styles */
.btn-primary {
  background-color: #3498db;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
}
Step 2

See Automatic CSS Minification

The output updates on its own. Comments and extra whitespace are gone, but every value is still spelled the way you typed it. Minifying does not remove rules you never use; for that, see removing unused CSS.

Minified CSS Output

The example above comes out like this:

.navbar{background-color:#2c3e50;padding:1rem 2rem;box-shadow:0 2px 4px rgba(0,0,0,0.1)}.btn-primary{background-color:#3498db;color:white;border:none;padding:0.75rem 1.5rem;border-radius:4px}
Size reduction: 278 bytes → 191 bytes, about 31% smaller
Step 3

Copy or Download Your Minified CSS

Copy the minified CSS to your clipboard or download it as minified-styles.css, ready to improve your website's performance.

•
Faster page loading with reduced file sizes
•
Reduced bandwidth usage for better mobile performance
•
Improved SEO scores through faster loading times
•
Production-ready CSS for deployment

What is CSS Minification? ⚡

CSS minification is the process of removing unnecessary characters from CSS code without changing its functionality. This tool removes whitespace, comments and the last semicolon in each block. Some minifiers go further and rewrite values (0.10 to .1, for example); this one leaves every value as you wrote it.

Minified CSS loads faster, uses less bandwidth, and improves website performance. It's an essential optimization technique for production websites, especially for mobile users and slower internet connections.

Frequently Asked Questions

How much smaller will my CSS get?

It depends on how the file is written. A heavily commented, indented stylesheet shrinks a lot; one that is already compact barely changes. The badge above the output shows the real byte count before and after, so you can see the saving for your own file. The short example on this page goes from 278 to 191 bytes, about 31% smaller.

Can minifying break my styles?

It is built not to. The minifier only removes comments and the whitespace between tokens. Text inside quotes, url() paths, escaped characters and custom property values (--name: ...) are copied as typed. Spaces that CSS needs are kept, such as the ones around + and - in calc(1px + 2px) and the space before "and (" in a media query. Numbers are not rewritten either, so 14.50 stays 14.50.

Which comments are kept?

Comments that start with /*! are kept, because that is the usual way to mark a license or copyright notice that has to ship with the file. Every other comment is removed.

What happens if my CSS has a mistake in it?

If a string or a comment is never closed, or a url( has no closing bracket, you get the line and column where it starts instead of output. Other mistakes, like a misspelled property, are not checked; they are minified as they are, and the browser will ignore them just as it would in the original file.

When should I use minified CSS?

Ship the minified file to production and keep the formatted one in your project for editing and debugging. If you already run a build tool such as PostCSS, Lightning CSS or cssnano, it can do this step for you; this page is handy for a one-off file or a quick check.

Is my CSS uploaded anywhere?

No. The minifying runs in your browser, so the stylesheet you paste or upload is not sent to our server.