HTML Minify API - Strip Comments and Collapse Whitespace
Removes <!-- --> comments, collapses whitespace between tags to a single space, removes internal whitespace runs, drops blank lines, and strips newlines between tags. Returns minified output plus original and minified byte counts and savings percent.
Code examples
curl -X POST https://api.botoi.com/v1/minify/html \
-H "Content-Type: application/json" \
-d '{"code":"<!DOCTYPE html>\n<html>\n <body>\n <!-- banner -->\n <h1>Hello</h1>\n </body>\n</html>"}'When to use this API
Minify server-rendered HTML at the edge
Pipe the output of your server framework through this endpoint before returning to the browser. Reduces first-byte payload without touching your render templates.
Pre-compress static HTML files
Build-step minification for Astro, Hugo, or 11ty output. The savings stack with Brotli, taking 10 KB HTML pages down to 2-3 KB on the wire.
Email template optimization
Transactional emails often have bloated HTML from WYSIWYG editors. Minify before sending to cut message size and improve deliverability (some providers penalize large bodies).
Frequently asked questions
Does it break <pre>, <script>, or <style>?
Are conditional comments preserved?
What about HTML attribute whitespace?
How does this compare to html-minifier-terser?
What is the savings range?
Get your API key
Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.