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

JavaScript Minifier

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

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


    // setup the URL and read the JS from a file
    $url = 'https://javascript-minifier.com/raw';
    $js = file_get_contents('ready.js');

    // init the request, set various options, and send it
    $ch = curl_init();

    curl_setopt_array($ch, [
        CURLOPT_URL => $url,
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => ["Content-Type: application/x-www-form-urlencoded"],
        CURLOPT_POSTFIELDS => http_build_query([ "input" => $js ])

    $minified = curl_exec($ch);

    // finally, close the request

    // output the $minified JavaScript
    echo $minified;

Also, Toni Almeida has made a PHP library to easily talk to JavaScript Minifier : https://github.com/promatik/PHP-JS-CSS-Minifier.

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/javascript-minifier.com.

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