HTML Minifier

Remove comments and extra whitespace from HTML.

Also called: HTML compressor, minify HTML.

FreeNo sign-upRuns in your browser
DEVELOPER

HTML Minifier

Remove comments and extra whitespace from HTML.

Runs locally in your browser
Ready. Fill in the fields above, then press Run tool.
Privacy note: this tool runs in your browser, so the text you enter stays on your device.

Find a tool

Loading tools…

Watch: how to use the HTML Minifier (12 seconds)

Recorded on a phone, steps written on screen, no sound.

About the HTML Minifier

Make HTML smaller by removing comments and extra whitespace. Keep the readable original for editing.

What is removed

Comments (except Internet Explorer conditional comments), line breaks and repeated spaces, and the spaces between block tags such as div, p, li and table rows. The result shows how many characters were saved.

The content of pre, textarea, script and style blocks is left exactly as it is, so code samples and scripts keep working. Check the page once after minifying, then keep your readable original for editing.

How to use the HTML Minifier

  1. Enter your textType or paste HTML.
  2. Press Run toolThe result appears right under the button.
  3. Copy or download the resultCopy text results with Copy output; when the tool makes a picture or file, use its Download button.

This tool works inside your browser: what you enter stays on your device.

Example

A sample input and the result the HTML Minifier gives for it (produced by the tool itself, not typed by hand).

HTML
<!-- page header --> <header class="top"> <h1> Welcome </h1> <p>Fresh coffee, every day.</p> </header>

Result:

<header class="top"><h1> Welcome </h1><p>Fresh coffee, every day.</p></header>

— 108 → 78 characters

Good to know

What you need
You type or choose: HTML
Where it runs
In your browser, on your device.
Cost
Free, no sign-up.

Questions

Will it break <pre> blocks?

Check pages with preformatted text after minifying.

How much smaller?

Usually 5–20%, more with many comments.

More tools in Developer

See all Developer tools