Minify your HTML

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

w3tees

Support HTML Minifier by purchasing a w3tees t-shirt. This site is also run by us.

PHP

<?php
    // setup the URL, the CSS and the form data
    $url = 'http://html-minifier.com/raw';
    $html = file_get_contents('./index.html');
    $data = array(
        'input' => $html,
    );

    // init the request, set some info, send it and finally close it
    $ch = curl_init($url);

    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $minified = curl_exec($ch);

    curl_close($ch);

    // output the $minified
    echo $minified;
?>

Language Examples

Click on the language of your choice:

wget Curl Node.js Python Ruby Perl PHP C#

More Languages

I'd love to add more examples in your favourite programming language, so feel free to send them my way. Email andychilton at that gmail place in the sky or tweet to me @andychilton.