HTML Minifier
Shrink HTML by collapsing whitespace and removing comments. pre/script/style and significant inline spacing are preserved. Runs in your browser; nothing is uploaded.
About this tool
HTML Minifier shrinks HTML for faster delivery by:
- Collapsing whitespace — indentation and newlines between tags are removed, and runs of whitespace inside text are collapsed to a single space.
- Removing comments —
<!-- … -->blocks are stripped (tick Remove comments; leave it off to keep them). - Normalizing tag whitespace — extra spaces between attributes are collapsed.
It's built to be safe:
- Significant inline spacing is preserved — a real space between inline
elements (e.g.
<b>a</b> <b>b</b>) is kept, so words don't run together. <pre>,<textarea>,<script>and<style>keep their contents verbatim, so code and whitespace-sensitive blocks aren't broken.- Attribute values are never touched.
Everything runs locally in your browser via WebAssembly — your HTML is never uploaded. The reverse tool is HTML Formatter (pretty-print).
FAQ
Will minifying make words run together?
No. A run of whitespace inside text collapses to a single space, never to
nothing, and a meaningful space between inline elements — like
<b>bold</b> <i>italic</i> — survives. Only the purely structural whitespace
(indentation and newlines between block tags) is removed outright.
Does it also minify the JavaScript and CSS inside my page?
Deliberately not. <script> and <style> contents are passed through
verbatim, because whitespace-collapsing rules that are safe for HTML can
break string literals, template literals or CSS calc() expressions. Run the
extracted code through a dedicated JS/CSS minifier if you need that too.
What happens to <pre> blocks and attribute values?
<pre> and <textarea> keep their exact original whitespace, so code samples
and form defaults render unchanged. Attribute values are never modified
either — only the extra spaces between attributes inside a tag are collapsed.
Can I keep my HTML comments?
Yes — untick Remove comments. That preserves every <!-- … --> block,
which you'll want if your page relies on comment-based markers (build-tool
injection points, IE conditional comments, license headers).
Developer & Automation Access
Run it from the terminal
Same engine as this page, headless — via the gizza CLI:
gizza tool html-minifier "<div>
<p>Paste your HTML here</p>
</div>"New to the CLI? Get gizza →
Open it by URL
Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:
https://gizza.ai/tools/html-minifier/?html=%3Cdiv%3E%0A%20%20%3Cp%3EPaste%20your%20HTML%20here%3C%2Fp%3E%0A%3C%2Fdiv%3E&remove_comments=trueMachine-readable descriptor: tool.json — title + parameters JSON Schema for agents.
