HTML Minifier
Runs locallyMinify HTML markup safely while preserving preformatted blocks and tracking byte savings.
What is HTML Minifier?
Reduce HTML payload size by collapsing whitespace between tags and stripping HTML comments while protecting <pre>, <code>, and <textarea> contents.
How to use HTML Minifier
- Step 1
Paste HTML into the input editor.
- Step 2
Toggle comment removal and whitespace options.
- Step 3
Copy or download the compressed HTML.
Features
- Preserves whitespace inside <pre>, <code>, and <textarea>
- Optional HTML comment stripping
- Byte savings percentage in the status bar
- Integrated HTML validator diagnostics
- Switch instantly to Format or HTML to JSX
- Runs locally in your browser
Example
Input
<!-- header --> <div class="box"> <span>Hi</span> </div>
Output
<div class="box"><span>Hi</span></div>
Removes comments and inter-tag indentation.
Frequently asked questions
Does HTML Minifier preserve conditional comments or <pre> blocks?
Whitespace inside <pre>, <code>, and <textarea> is always preserved.
How much size does minification save?
The status bar shows the exact percentage reduction in bytes.
Are my templates sent to a server?
No, everything runs locally.
Can I beautify the HTML again?
Yes, switch the mode to Format.
Related tools
HTML Formatter & Validator
Beautify, minify, validate HTML, convert to JSX/Markdown and preview safely.
CSS Minifier
Compress CSS stylesheets while preserving calc() expressions and showing byte savings.
SVG Optimizer
Optimize SVG with SVGO, preview safely and export SVG, React, Vue, Data URI or Android Vector.