How to use the HTML Minifier tool
- Add your HTMLDrop in the markup of a page or template, or choose a file from your computer.
- Choose optionsDecide whether to delete comments, squash spacing, shrink embedded styles and schema data, and remove optional quote marks.
- Review the outputThe compressed markup shows up straight away, together with the number of bytes saved and a gzip estimate.
- Copy or saveCopy it, or save it to disk with a .min.html extension.
HTML minifier features
- Whitespace done rightGaps between block elements are removed and spaces inside text are collapsed, so words stay correctly spaced.
- Untouched code blocksPreformatted text, text-area defaults and scripts are passed through unchanged, so code examples and form values survive.
- Inline CSSCompresses <style> blocks and style="" attributes using the CSS minifier.
- JSON-LD schemaCompacts structured data markup while keeping it valid.
- Special comments keptOld Internet Explorer conditional blocks and comments starting with <!--! stay in place.
Why minify HTML?
A browser has to download every byte of HTML before it can finish building the page. Cutting comments, indentation and redundant attributes trims page weight, frequently by 10–25%, helping pages appear sooner on slow mobile networks and improving Core Web Vitals.
What each option does
- Remove comments: notes such as
<!-- footer links -->disappear. - Collapse whitespace: indentation between tags vanishes, and
Good daybecomesGood day. - Remove default type attributes:
<style type="text/css">becomes<style>. - Shorten boolean attributes:
disabled="disabled"becomesdisabled. - Remove optional quotes:
dir="ltr"becomesdir=ltr, which is valid HTML5 but switched off by default.
Is minifying HTML safe?
This tool is intentionally cautious. Spacing around inline tags such as links, bold text and spans shrinks to a single space rather than disappearing, because removing it entirely could merge neighbouring words. Preformatted blocks, text areas and script elements are reproduced character for character. Even so, preview the result before it goes live and hold on to your readable source for future edits.
More ways to speed up your site
- Enable server-side compression (Gzip or Brotli) to cut transfer sizes further still.
- Run your style sheets through the CSS Minifier and your code through the JavaScript Minifier.
- Pictures tend to outweigh everything else on a page, so shrink them using the Image Compressor.