TextyConverterbeta
⌘K

HTML Minifier

Strip insignificant whitespace and HTML comments to shrink your markup. Browser-only.

0 characters
0 characters

About HTML Minifier

The HTML minifier removes whitespace between tags and strips HTML comments to produce a smaller document. Whitespace inside tags that treat it as significant (script, style, pre, textarea) is preserved. The result renders identically to the input in any modern browser and is byte-for-byte smaller.

When to use it

  • Reducing HTML payload size before HTTP compression (gzip/brotli already helps, but minification compounds)
  • Stripping authoring comments before publishing
  • Producing a more compact HTML string for inlining in JavaScript
  • Preparing HTML for templates that have a per-line size limit

How it works

A pass strips HTML comments (<!-- ... -->) outside of <script> and <style> blocks. A second pass collapses whitespace between adjacent tags. Content inside elements where whitespace is significant — <pre>, <textarea>, <script>, <style> — is left untouched.

Examples

Inter-tag whitespace and comments removed
<html>
  <!-- header -->
  <body>
    <p>
      hello
    </p>
  </body>
</html>
<html><body><p> hello </p></body></html>

Frequently asked questions

Will my page render the same?
For typical HTML, yes. The minifier preserves whitespace where it matters (pre, textarea, script, style). In rare edge cases where inline elements rely on space characters between them, output may differ very slightly.
How much smaller will my HTML be?
Indented HTML typically shrinks 20–40%. Documents that are already mostly content (long paragraphs of text) shrink less; heavily structured layouts shrink more.
Does this also minify embedded CSS and JS?
No. Embedded <script> and <style> content is preserved as-is. To minify those, use the JavaScript minifier and CSS minifier separately and inline the results.
Are HTML attributes shortened?
No. This is a whitespace-only minifier. Attribute deduplication and boolean-attribute collapsing are not performed.

Related tools