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

HTML Minifier

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


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 = "";

    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");


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