This site has been acquired by Toptal.com.
(Attention! API endpoint has changed)

HTML Minifier

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

Perl

Thanks to Boris Kotyrev (I've adapted what he sent to be more minimal).

use strict;
use warnings;

use File::Slurp;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

sub minify{
    my ($html) = @_;

    my $html_min_url = "https://www.toptal.com/developers/html-minifier/raw";

    my $ua = LWP::UserAgent->new;
    my $request = POST($html_min_url, [ 'input' => $html ]);
    my $html_min = $ua->request($request)->decoded_content();

    return $html_min;
}

print minify($html, "\n");

Languages

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