Minify HTML: comments and extra space go, inline CSS and JS are minified, <pre> and attribute values stay as written
Make a page smaller without changing how it shows: comments and the space a browser ignores go, and the CSS and JavaScript inside it are minified too.
How to use it
Paste HTML, or open an .html file. The result shows at once; the status bar says how many characters it has and how much smaller it is. Under Options, keep comments or line breaks, drop optional end tags, default attributes and quotes, write booleans bare, sort classes, keep template tags, or set a maximum line length. Copy it or download minified.html. Switch Mode to Format to make it readable again.
Examples
Comments and spaces go, words keep one space
<ul class="nav"> <!-- main links --> <li><a href="/">Home</a></li> <li><a href="/docs" >Docs</a></li> </ul> <p>Read the <b>docs</b> first.</p>
<ul class="nav"><li><a href="/">Home</a></li><li><a href="/docs">Docs</a></li></ul><p>Read the <b>docs</b> first.</p>
<pre> stays, <style> is minified
<pre>
two spaces
stay
</pre>
<style>
.note { color: #555555; }
</style><pre>
two spaces
stay
</pre><style>.note{color:#555}</style>What goes, what stays
Comments go, except conditional ones (<!--[if IE]>) that old browsers still read. Runs of space become one space, and none at all next to block elements like <div>, <p> and <li>, where it doesn’t show. Between inline elements like <a> and <b> one space stays, because it shows as a gap between words. <pre>, <textarea> and attribute values stay as written; scripts of other types (JSON-LD, templates) too. Inline <style> is minified by csso and inline <script> by Terser. Code they can’t read stays as written, with a note.
Going further, under Options
Questions
- Will the minified page look different?
It shouldn’t: only space a browser ignores is removed. If a page relies on CSS like white-space: pre on an element other than <pre>, check that part, since its space is collapsed. - Can it read a template with {{ }} or <% %>?
Text between tags is left alone apart from spaces, so most template tags pass through. Turn on Keep template tags under Options to leave {{ }}, {% %}, {# #} and <% %> exactly as written, spaces inside and tags holding them included. - Is my HTML uploaded?
No. Everything runs in your browser, so your page stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first.