go-supertools
Developer & Data Tools

HTML Minifier

Minify HTML Code

Runs in your browser Your input never leaves your device.

About this tool

Makes HTML smaller in three steps: it removes comments (but keeps IE conditional comments), collapses runs of whitespace into one space, and deletes the whitespace between tags next to block-level tags such as div, p, li or table. The content of pre, textarea, script and style elements is left exactly as written, so preformatted text and inline scripts (including // line comments) keep working. A single space between two inline tags, for example between two links or </b> <i>, is kept so words do not run together. This is a text pass, not an HTML parser: it does not remove optional tags, quotes or attribute values. Always check the output in a browser. Everything runs on your device.

How to use it

  1. Paste your HTML.
  2. Run the minifier and review the output.
  3. Test the page, especially any pre blocks or inline scripts.
  4. Use the minified version in production and keep the original.

Example

Input
<div>
  <!-- c -->
  <p>Hello   world</p>
</div>
Result
<div><p>Hello world</p></div>

Common problems

The output is only slightly smaller
Whitespace inside pre, textarea, script and style is deliberately not touched, and inline spaces are kept. Minify scripts and styles with their own tools.
Words next to inline tags still have spaces
One space between inline elements is kept on purpose, because removing it would join the words on screen.
Conditional comments or special markup changed
IE conditional comments are kept. Other comments are removed, including ones some frameworks use as markers. Check the result before using it.