CSS cleaner for expanding style sheets?

I am looking for a web service or (OS X) software that will take a stylesheet similar to this:

h1,h2 {margin-bottom:1em;}
h2.special {color:red;text-align:justify;}
p {margin-bottom:1em;font-weight:bold; }

and convert it to this:

h1,h2,p {margin-bottom:1em;}
h2.special {color:red}
h2.special {text-align:justify;}
p {font-weight:bold;}

Ie I need something that takes every unique combination of attributes / values ​​in the CSS file and then groups all the selectors that use it.

It seems to me that this is a trivial problem, but the only bit of β€œcoding” capable of Im is a bit of RegEx - it seems that this does not give me a solution here.

Thank.

Note:

I know that such an approach cannot lead to optimization (dimension). This is not for a live site / CSS, but for the analysis and "screening" of unnecessarily complex stylesheets. After this step, the attributes will be grouped again.

+5
4

: http://www.cssoptimiser.com/optimize.php , h2.special {color:red;text-align:justify;}

h2.special {color:red}
h2.special {text-align:justify;}

. (margin-bottom).

Google CSS

+3

CSS, : http://lesscss.org/

CSS, CSS.

+1

Compass http://compass-style.org/. Ruby CSS-

0

, ( +1, , ), "", , Dust Me Selectors Firefox.

0

All Articles