We've been hosted on Digital Ocean since 2013 and highly recommend it for your hosting too. Try it now!

CSS Minifier

Online CSS Minifier/Compressor. Free! Provides an API. Simple Quick and Fast.

Written and hosted by Andrew Chilton (@andychilton) since 2009.

No ads in .

Node.js

Using just core packages (no packages from npm):

var querystring = require('querystring');
var http  = require('http');

var query = querystring.stringify({
    input : css
});

var req = http.request(
    {
        method   : 'POST',
        hostname : 'http://localhost:80',
        path     : '/raw',
    },
    function(resp) {
        // if the statusCode isn't what we expect, get out of here
        if ( resp.statusCode !== 200 ) {
            console.log('StatusCode=' + resp.statusCode);
            return;
        }

        resp.pipe(process.stdout);
    }
);
req.on('error', function(err) {
    throw err;
});
req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
req.setHeader('Content-Length', query.length);
req.end(query, 'utf8');

Many people have sent language examples over the years, but we want more! We'd love to add more examples in your favourite programming language, so please send them our way. Email andychilton at that gmail place in the sky, tweet me @andychilton, or open an issue or PR on webdev-sh/cssminfier.com.

Click on the language of your choice to see an example: