HTML Minify
Minify HTML: remove comments and collapse extra whitespace while keeping <pre>, <textarea>, <script> and <style> blocks untouched, so the page still renders the same. Runs in your browser.
Suggested tools
About HTML Minify
HTML Minifier reduces the size of HTML by removing comments and collapsing runs of spaces, tabs and line breaks, and by dropping whitespace around block-level tags where it never shows on screen.
It keeps what matters: content inside <pre> and <textarea> (where spaces are visible) and <script>/<style> blocks are left exactly as they are, the single space between inline elements like "<b>Hello</b> <i>World</i>" is preserved, and IE conditional comments are kept. Everything runs locally in your browser — the text you paste is never uploaded.
How to use HTML Minify
- Paste your HTML or upload a file.
- Press Minify.
- Copy or download the compact HTML.
Key features
- Removes comments and redundant whitespace
- Leaves <pre>, <textarea>, <script> and <style> untouched
- Keeps meaningful spaces between inline elements
- Safe for email templates and static pages
Example
The comment and extra spaces go; the <pre> block is left exactly as it was.
<div class="card"> <!-- price --> <p> Pen </p> <pre> keep this </pre> </div>
<div class="card"><p>Pen</p><pre> keep this </pre></div>
When to use HTML Minify
- Making static pages and email templates smaller.
- Compacting HTML before embedding it in JSON or a database field.
- Removing developer comments before publishing a page.
Tips and common problems
- Content in <pre>, <textarea>, <script> and <style> is left untouched on purpose.
- Check the page afterwards if it relies on spaces between inline elements for layout.
- Minify CSS separately with CSS Minifier.
Frequently asked questions
No — script and style blocks are kept as they are, to avoid breaking them. Minify CSS separately with CSS Minifier.
Usually 10–25%, more for heavily indented or commented templates. Server compression (gzip/brotli) saves more on top.
Use HTML Formatter to re-indent the markup. Removed comments cannot be recovered, so keep your original.