Convertur

HTML minifier

HTML minifier that removes comments and collapses whitespace between tags for a smaller page. Leaves scripts and styles alone. Runs in your browser.

Loading tool...

How to minify HTML

Paste your markup into the input pane and click Convert. Normal comments are removed, whitespace between tags is dropped and runs of spaces inside text collapse to one. The contents of script, style, pre and textarea tags are set aside first and put back unchanged. Copy the minified HTML or download it as a file.

Why minify HTML

Smaller markup downloads faster and shows up sooner. It's an easy win for landing pages and emails.

Safe for scripts, with one layout caveat

Conditional comments are kept, and so is everything inside script, style, pre and textarea blocks, so scripts and preformatted text are safe. Whitespace between two tags is removed completely, though. Two inline elements separated only by a space, such as <b>Hi</b> <i>there</i>, end up touching and lose the visible space. Put the space inside one of the tags or use &nbsp; where it matters.

Where minifying helps most

Smaller markup downloads faster and shows up sooner, which helps landing pages, single-file apps and HTML emails, where some clients clip messages above about 100 KB. Server compression with gzip or Brotli already shrinks HTML a lot, so minifying matters most where compression isn't applied, such as inline templates and emails.

Before you start

Input: HTML and HTM. Output: Minified HTML. The settings appear before anything runs, so you can check them first. Your original file is never changed.

The value you enter is processed in your browser. Still test the output where it will be used. Clean formatting does not prove the data is safe or correct.

Keep the original until you have opened and checked the result. The work happens in this browser tab, so the size you can handle depends on your device's memory, your browser and the file itself.

How to use the HTML minifier

  1. Paste your HTML into the input pane.
  2. Click Convert to minify it.
  3. Copy the markup or download it as an .html file.

Last updated · How we build and check tools · Report an error

Learn more

Related tools

HTML Minifier FAQ