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.


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=' ... 

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(


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