Developer Tools

HTML Minifier

Strip comments and collapse unnecessary whitespace from your HTML to shave bytes off the page before it ships.

Size comparison will appear here after minifying.
Advertisement space

How HTML Minifier Works

The minifier removes HTML comments, deletes text nodes that contain only whitespace (the indentation between tags), and collapses remaining runs of whitespace inside text content down to a single space. Content inside <script> and <style> tags is left as-is so embedded code isn't affected.

How to Use This Tool

  1. Paste your HTML into the input box.
  2. Select Minify HTML.
  3. Copy the compact output and check the size reduction shown below it.

Example

Input:

<div>
  <h2>Title</h2>
  <!-- note -->
  <p>Text</p>
</div>

Minified output: <div><h2>Title</h2><p>Text</p></div>

Helpful Tips

  • Keep the original, readable HTML in your source files — minify only the copy you actually deploy.
  • Because whitespace-only text between tags is removed, minified output can slightly change spacing between inline elements — check the page visually after minifying if you use a lot of inline elements.

This tool runs entirely in your browser. Your input is not uploaded to any server.