How to use the HTML Minifier tool
- Paste or open your HTMLPaste a page or template, or click “Open file” to load an .html file.
- Pick your optionsRemove comments, collapse whitespace, minify inline CSS and JSON-LD, and optionally remove attribute quotes.
- Check the resultThe minified HTML appears instantly with the size saved and the gzip estimate.
- Copy or downloadCopy the output or download it as a .min.html file.
What it does
- Smart whitespaceRemoves whitespace between block elements and collapses it inside text, so spacing between words stays the same.
- Protected contentpre, textarea and script contents are never changed, so code samples and form defaults stay intact.
- Inline CSSMinifies <style> blocks and style="" attributes with the CSS minifier.
- Structured dataCompacts JSON-LD schema markup while keeping it valid.
- Conditional comments keptIE conditional comments and <!--! … --> comments are preserved.
Why minify HTML?
Every byte of HTML must be downloaded before the browser can start building the page. Removing comments, indentation and redundant attributes reduces page weight, often by 10–25%, which helps pages load faster on slow mobile connections and improves Core Web Vitals.
Options explained
| Option | Example |
|---|---|
| Remove comments | <!-- header --> is removed |
| Collapse whitespace | Indentation between tags is removed; Hello world becomes Hello world |
| Remove default type attributes | <script type="text/javascript"> → <script> |
| Shorten boolean attributes | checked="checked" → checked |
| Remove optional quotes | lang="en" → lang=en (valid HTML5, off by default) |
Is it safe?
The minifier is deliberately conservative. Whitespace between inline elements such as <b>, <a> and <span> is collapsed to a single space rather than removed, because removing it could join words together. Content of <pre>, <textarea> and <script> is copied exactly. Always test the minified page before deploying it, and keep your original source for editing.
Beyond minification
- Enable Gzip or Brotli compression on your server for an even bigger reduction.
- Minify your stylesheets with the CSS Minifier and scripts with the JavaScript Minifier.
- Compress images with the Image Compressor; images are usually the heaviest part of a page.