Minify your HTML

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

Digital Ocean

We recommend Digital Ocean for hosting your sites. Free $10 credit when you sign up.


Credits: Thanks to Cristian Tomatis for contributing this example.

import requests

url = ''
data = {'input': open('index.html', 'rb').read()}
response =, data=data)

print response.text

Python - from the REPL

Credits: Thanks to Noam Yorav-Raphael for contributing this example.

>>> import requests
>>>'', data=dict(input=' ... ')).text

Python - a CLI tool

Credits: Thanks to Kyle S. for contributing this to the site.

# -*- coding: utf-8 -*-
import sys
import requests

    html_file = sys.argv[1]
    print("Missing input file")

# Grab the file contents
with open(html_file, 'r') as c:
    html =

# Pack it, ship it
payload = {'input': html}
url = ''
print("Requesting mini-me of {}. . .".format(
r =, payload)

# Write out minified version
minified = html_file.rstrip('.html')+'.min.html'
with open(minified, 'w') as m:

print("Minification complete. See {}".format(

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.