HTML Minifier
HTML Minifier strips whitespace and comments from your HTML to reduce file size and improve page load speed. Paste any snippet or full document, choose your options and get compressed output instantly, with the size saved. No build tools or npm packages required.
HTML
Content inside <pre>, <textarea>, <script> and <style> is always kept byte for byte.
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Sample page</title><!--[if lt IE 9]><script src="html5shiv.js"></script><![endif]--><style>
.card { padding: 1rem; }
</style></head><body><div class="card" id="intro"><h1>Hello, world</h1><p>This paragraph has extra spaces and <strong>bold</strong> <em>words</em>.</p><pre>
Preformatted text
keeps its spacing
</pre><button type="button" disabled="disabled">Save</button></div></body></html>How to use
- Paste your HTML into the input box.
- Choose the options: collapse whitespace, remove comments (optionally keeping IE conditional comments), collapse boolean attributes and remove attribute quotes where safe.
- Check the minified output and the size saved; both update as you type.
- Copy the minified HTML or download it as an .html file.
Why use this tool?
Frequently asked questions
What is the HTML Minifier?
A browser-based tool that removes unnecessary whitespace and comments from HTML, reducing file size without changing how the page renders or behaves.
Will minifying HTML break my JavaScript or inline event handlers?
No. Content inside <script>, <style>, <pre> and <textarea> is kept byte for byte, and inline event handlers like onclick are preserved exactly as written. Whitespace is only removed next to block-level tags; a single space between inline elements such as links and bold text is kept, so text doesn't run together.
Is it free?
Yes, the HTML Minifier is free with no signup required. It runs entirely in your browser, so nothing you paste is uploaded. Built by the Canvas Builder team.
Stop tweaking snippets. Build the whole site
This tool fixes one piece. Canvas Builder builds the entire page from a single prompt: sections, copy, styling, and responsive layout. You own the code.