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

HTML Minifier

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

Ruby

Thanks to Jeremy Cron for contributing this example.

require "rest_client"

task :minify do
  html_file = "index.html"
  html_min_file = "html/index.html"
  response = RestClient.post "https://www.toptal.com/developers/html-minifier/raw", {:input => File.open(html_file).read}
  File.open(html_min_file, "w").write(response)
end

Languages

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