Example input
<span>A</span> <span>B</span>
<pre>A B</pre>
<script>const x = "a b";</script>
DataHub
Tools
HTML Minifier
Local-first
Minify HTML snippets by removing comments and unnecessary whitespace.
The minifier protects pre, textarea, script, and style blocks, removes ordinary non-conditional comments, collapses repeated horizontal whitespace elsewhere, and keeps one space between adjacent tags.
<span>A</span> <span>B</span>
<pre>A B</pre>
<script>const x = "a b";</script>The pre block and JavaScript string remain unchanged; ordinary surrounding whitespace is reduced.Template languages and application-specific comments can still have special meaning; compare rendered DOM and behavior before production use.
HTML and CSS define context-sensitive whitespace behavior. A global regular expression cannot safely preserve every parsing and rendering context.
Sources checked July 24, 2026. Specifications and platform behavior can change; verify the sources before formal use.
No. Template syntax and application-specific comments still require review.
Repeated horizontal whitespace outside protected blocks is collapsed, while one inter-tag space is retained.
Yes. pre, textarea, script, and style blocks are restored unchanged.
Yes. Compare DOM, rendering, templates, and behavior before deployment.