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

HTML Minifier

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

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

No ads in production.


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://html-minifier.com/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");


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

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