Start compressing...

Paste your css here
Not recommended (more info?)
Reset
>>> COMPRESS CSS <<<
Copy your new code
Select All

MINIFICATION RESULT:

Your file size:
??? characters!
Minified file size:
??? characters!
Difference:
??? characters!
Reduce rate:
??? percent(s)!

CAUTION!

Because the compressed code is hard to read and edit, we advice you to keep a copy of your original css file. That way, when you have to make any changes to your file, it will be a lot easy to edit the original one and then minified it again.

Why minify my CSS?

Minification is the practice of removing unnecessary characters from code, to reduce it's size thereby improving load time performance. When code is minified all comments are removed, as well as unneeded white space characters (space, newline, and tab). Additionally code would be further formatted onto a single line instead of multiple.

Most CSS can be compressed approximately to 1/5th of it's original size, sometimes even more! This minification tool work on Full Throttle and don't lose your time with annoying options and menus. The idea is to get the most minified and stable code, by clicking one button only. It's fully CSS3, Media Queries and IE hack compatible, so you don't have to worry about this. Just paste your code into the first textbox, click on 'compress' button and copy the generated code from the textbox below. You can find more information, about what this compressor do, at the sections below.

How it works?

This compressor is based on simple but well organized regular expression. It does not mess with your code as much as needed, because we want to prevent malfunctioning or any other form of unwanted behaviour to your website.

All of the described functionalities are carefully tested and worked well.
Here is a full list of all major actions that this compressor do:

  • Remove all comments See Example
  • Remove all empty selectors See Example
  • Remove all unneeded white space characters (space, newline, and tabs) See Example
  • Remove last ; See Example
  • Turns 0(em,px,pt,% .etc) to 0 See Example
  • Remove quotes from background url path See Example
  • Replace font-weight:bold/normal with 700/400 See Example
  • Reduce HEX color codes (#ffffff to #fff) See Example
  • Optimize margin, padding and box-shadow values See Example
  • Remove 0 from decimal fraction See Example

About Group styles

Grouping styles works as follows:
The function loops the whole css file in search of recurring styles. When the function detects two repetitive styles, it works as follows:
  1. It preserves the selectors, to which the set style belongs.
  2. It deletes this style in all places where it is found.
  3. It groups all gathered selectors from step 1 and assigns them the selected style, and all of this is added to the bottom of the css file.
Let's demonstrate this with an example.
See Example 1
See Example 2

It is important to note that this method of minification is not always as effective as the standard one. In our first example the input css contains 143 characters and the output css - 152. This means that in this case, css size increased by 9 characters, which is the opposite of what we want to achieve. However, if we run standard minification of the code from example one, it turns out that we saved 5 characters.
In the second example, however, we saved 43 symbols by grouping styles and with the standard minification of the code we would decrease it only by 7 characters. This shows the true power of this method. Considering the fact that we would apply these methods on css with a much larger volume, the differences in size become enormous. Such discrepancies occur, due to the nature of the work of this functionality. As you can tell from these examples, this method can work for you as well as against you.

We should note one major drawback of this method, because of which it is not recommended. Generating these new grouped styles, there is a danger of rewriting. This would lead to the breaking of your site layout.

See Example

If this code is executed #lang. container would have a gray background because #lang. container {background:#c0c0c0} is written after #header .container {background:red}. If we minify the code using grouping of styles we would have the following css:


.container{width:960px;margin:0 auto;padding:5px 0}
#header, #lang .container{background:#c0c0c0}
#header .container, #lang{background:red}

As seen after grouping the selector #header,#lang .container{background:#c0c0c0} is now before #header .container,#lang{background:red}, which means that #lang. container will have a red background. Here we observe rewriting of styles that will change the layout.
This rewriting can be avoided if the selectors of styles are defined very specifically.


before: .container{width:960px;margin:0 auto;padding:5px 0}
#header{background:#c0c0c0}
#header > .container{background:red}
#lang {background:red;}
#lang > .container{background:#c0c0c0}
In this case there is no danger of rewriting. after: .container{width:960px;margin:0 auto;padding:5px 0}
#header, #lang>.container{background:#c0c0c0}
#header>.container, #lang{background:red}

Of course, if you have a large amount of styles, however the effort, it is very much possible to obtain such rewriting. Therefore, the use of this feature is not recommended because it can not guarantee that the outcome wouldn’t break your site.
On the other hand, this instrument that can give you guidance on the stability of your styles. If you want to have right set styles, that are in no way possible to rewrite each other, this is the ideal tool for inspection.

© 2013 COMPRESS CSS by Kaloyan Stamatov Google