HTML Minifier
Conservatively compact HTML tag syntax while retaining text whitespace and comments. Runs entirely in your browser.
Why Minify HTML? — Reduce File Size and Improve Core Web Vitals
This tool performs conservative HTML tag-whitespace compaction. It does not remove text-node whitespace, comments, or optional tags. Rendering and performance should be verified in your target browser.
What This Tool Preserves
- Text content, including separators between inline elements, is retained.
- Script, style, preformatted, and raw-text blocks are retained.
- Quoted attribute values and comments are retained; only extra whitespace in tag syntax is compacted.
How Much Does HTML Minification Save?
Savings may be small or zero because text whitespace and comments are preserved. This is not a full HTML parser or a replacement for a tested production minifier. Measure actual transfer sizes with your server compression enabled.
HTML Minification Best Practices
- Minify in your build pipeline — Use tools like html-minifier-terser, HTMLMinifier, or Webpack html-loader in CI/CD
- Keep source files unminified — Always minify from the original source; never edit minified HTML directly
- Combine with server compression — Enable gzip or Brotli compression on your web server (Nginx, Apache, CloudFlare)
- Preserve
<pre>and<code>whitespace — Minifiers should not collapse whitespace inside preformatted text blocks
Frequently Asked Questions
Script and style blocks, quoted attributes, and comments are retained rather than minified. This lightweight tokenizer is not a full HTML parser; test output, especially malformed markup or unusual embedding contexts.
The tool preserves text-node whitespace, including spaces between inline elements and preformatted content. It only compacts whitespace in recognized tag syntax; verify rendering before production use.
SVG text and quoted attributes are retained. The tool does not perform SVG-specific optimization or validation, so review the result in a browser.
Input processing is local to this tool. Shared page features may make network requests, and enabled browser drafts may retain text locally. Avoid pasting credentials or confidential material.
Source compaction and gzip/Brotli can be combined. This conservative tool may make little difference after compression; measure the actual benefit rather than expecting a fixed reduction or faster page load.