Skip to content
AlroundTools

HTML minifier

Minify HTML by removing comments and collapsing whitespace, while keeping pre, textarea and script content intact.

Runs in your browser – your files are not uploaded

How to use HTML minifier

  1. 1

    Paste your HTML into the input field.

  2. 2

    Choose whether to remove comments, collapse whitespace and minify inline CSS.

  3. 3

    Copy the minified HTML or download it as a file.

About HTML minifier

The HTML minifier removes comments, collapses runs of spaces and line breaks, and tidies whitespace inside tags. Optionally it also minifies CSS inside <style> blocks. You see the size before and after at a glance.

Safety comes first: the content of <pre>, <textarea> and <script> elements is kept exactly as written, conditional comments for old browsers are preserved, and whitespace between inline elements is reduced to a single space rather than removed – so “<b>a</b> <i>b</i>” still shows a space. Whitespace is only removed next to block-level elements, where it has no visible effect.

Frequently asked questions

Will my JavaScript be minified?

No. Script content is kept unchanged on purpose, because minifying JavaScript safely requires a full parser. Use a dedicated build tool for that.

Why are some spaces kept?

Between inline elements and text, a space is visible on the page. The minifier keeps one space there so the rendered text does not change.

Does it work with templates?

It works with plain HTML. Template syntax from frameworks is usually left alone, but check the output if your templates rely on exact whitespace.