Minify your HTML without breaking anything
The HTML minifier shrinks your markup by stripping what the browser doesn’t need: comments, line breaks and indentation, and the leftover whitespace between tags. The output is smaller, travels faster over the network and shaves a little off your load time and performance metrics — all without changing how the page looks or behaves.
Everything happens in your browser: paste the HTML, get the minified version instantly, and your code is never sent to any server.
How to use it
- Paste your HTML into the input box.
- Copy the minified HTML with the button (or check the bytes and percentage you saved).
- Drop it into your project, email template or static file.
What it does exactly
- Removes comments
<!-- ... -->. - Collapses every run of spaces, tabs and line breaks into a single space.
- Deletes the gap between tags: the whitespace sitting between a
>and the next<is removed entirely. - Leaves untouched the contents of
<pre>,<textarea>,<script>and<style>, plus quoted attribute values. A stray space does matter there, so it stays put.
| Element | Minified? |
|---|---|
Comments <!-- --> | Removed |
| Whitespace between tags | Removed |
| Multiple spaces in text | Collapsed to one |
<pre> and <textarea> content | Preserved |
<script> and <style> code | Preserved |
| Attribute values | Preserved |
Worked example
Start from this HTML with a comment, indentation and a <pre> block:
<!-- Product -->
<div class="card">
<h1>Hello world</h1>
<p>Welcome to the portal.</p>
<pre> line 1
line 2</pre>
</div>
That’s 137 bytes. After minifying we get:
<div class="card"><h1>Hello world</h1><p>Welcome to the portal.</p><pre> line 1
line 2</pre></div>
Now it’s 99 bytes — a 27.7% saving. Notice three things: the comment is gone, the triple space in “Hello world” collapsed to one, and the meaningful indentation inside <pre> was kept line by line.
Frequently asked questions
Does minifying HTML help SEO?
Indirectly. Google doesn’t reward markup for being minified, but a lighter file loads a touch faster, and speed is a real experience signal. The impact is small next to compressing images or enabling gzip/Brotli on the server, but it adds up and it’s free.
Can it break my page?
It shouldn’t. The tool never touches the contents of <pre>, <textarea>, <script> or <style>, nor your attribute values — the places where an extra space would change the outcome. Everywhere else HTML ignores repeated whitespace, so collapsing it is safe.
Should I keep the unminified HTML too?
Yes. Always work on the readable (indented) version and minify only the copy you ship. If you later need a comfortable-to-read format again, use the HTML formatter, which does the opposite: it puts line breaks and indentation back.
Is it useful for HTML emails?
Yes, and it shows there: many email clients have size limits and clip long messages (Gmail clips around 102 KB). Minifying the email’s HTML helps you stay under the limit.
Is my HTML uploaded anywhere?
No. The whole process runs in your browser with JavaScript. You can paste private code and it never leaves your machine.