Minify your HTML

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


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


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

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.