HTML Minifier
Strip comments and unnecessary whitespace from HTML to shrink file size.
What is HTML Minifier?
An HTML minifier strips the parts of a document that exist purely for human readability — comments and the extra whitespace between tags — without changing how the page renders, shrinking the file that has to be downloaded and parsed. This matters most for pages generated once and served many times (a static export, an email template, a widget embedded on someone else's site) where every byte saved is bandwidth saved on every future request. This tool runs entirely in your browser and is careful about what it touches: content inside <script>, <style>, <pre>, and <textarea> is left completely untouched, because whitespace inside those elements is meaningful — collapsing it would break JavaScript syntax, CSS formatting, preformatted text, or a textarea's default value.
How to Use HTML Minifier
- Paste your HTML into the input box.
- The minified result appears instantly on the right, along with how many bytes and what percentage it shrank by.
- Click "Copy" to grab the minified output.
Examples
Comments and whitespace
Input: <div> <!-- note --> <p>hi</p> </div>
Output: <div><p>hi</p></div>
Text node with extra spacing
Input: <p>hello world again</p>
Output: <p>hello world again</p>
Common Mistakes
- Minifying, then trying to debug the output directly — minified HTML is meant for production delivery, not for reading; keep your original, readable source and only minify at build/deploy time.
- Assuming this also minifies inline CSS/JS syntax itself (removing unnecessary characters inside a <script> or <style> block) — it doesn't; it only removes HTML-level whitespace and comments, and deliberately leaves script/style bodies untouched.
- Running already-minified output back through the tool expecting further savings — there's little left to strip once whitespace and comments are already gone.
- Forgetting that HTML comments containing conditional logic some old tools relied on (like legacy IE conditional comments) are stripped along with ordinary comments — if you still need those for a specific legacy use case, keep an unminified copy.
Why Use This Tool
- Processes entirely client-side — nothing you paste is sent to a server.
- Protects <script>/<style>/<pre>/<textarea> content instead of blindly collapsing all whitespace.
- Shows exactly how many bytes and what percentage you saved on your specific input.
- No build tooling or configuration required — paste and get a result immediately.