HTML Minifier

Shrink HTML files with advanced minification. Remove comments, collapse whitespace, minify inline CSS & JS — all locally in your browser.

Minifier
Original:0 B
Minified:0 B
0 B

Aggressive Minification

Strip comments, collapse whitespace, remove empty attributes, and optionally drop optional closing tags. Every byte counts.

Inline CSS & JS

Minify contents of <style> and <script> blocks too. Removes comments and unnecessary whitespace from embedded code.

Private & Local

Everything runs in your browser. Your HTML files, inline scripts, and proprietary markup never leave your device.

Why minify HTML?

Every byte of HTML has to travel over the network and be parsed by the browser. Minification reduces the number of bytes without changing the visual output, which means faster page loads and lower bandwidth costs. For mobile users on slow connections, the difference is especially noticeable.

What gets removed

The minifier strips HTML comments, collapses runs of whitespace, removes empty attributes, and optionally omits default boolean attribute values and optional closing tags. It also minifies inline CSS and JavaScript inside<style> and <script> blocks. Content inside <pre> and <textarea> is always preserved verbatim because whitespace there is semantically significant.

When not to minify

Only minify the version you ship to production. Keep the original, un-minified file in version control and as your source of truth. If you serve HTML to XML-based consumers (RSS readers, XHTML parsers, or some build pipelines), be cautious with optional closing tags and unquoted attributes — those features are valid HTML5 but may confuse strict XML parsers.

Frequently asked questions

What does the HTML minifier do?

It removes unnecessary whitespace, comments, empty attributes, and optional closing tags from HTML to reduce file size. The rendered output of the page stays exactly the same — only the source code is compressed.

Will minifying break my website?

No. The minifier only removes content that is invisible to browsers: extra spaces between tags, HTML comments, and optional markup. It preserves <pre>, <textarea>, <script>, and <style> blocks where whitespace is meaningful.

What is 'Remove optional closing tags'?

HTML5 allows omitting certain closing tags (like </p>, </li>, </td>) where the parser can infer them automatically. Enabling this removes those tags for a smaller file, but some older XML-based pipelines may require them.

Can I minify inline CSS and JavaScript?

Yes. When enabled, the tool strips comments and collapses whitespace inside <style> and <script> blocks. It performs conservative minification that is safe for the vast majority of code.

What are boolean defaults?

Boolean attributes like checked, disabled, readonly, and required can be written as just checked instead of checked='checked'. Removing the redundant value saves a few bytes per attribute.

Does it remove attribute quotes?

When safe, yes. HTML5 allows unquoted attribute values that contain only letters, numbers, dots, hyphens, and underscores. Removing quotes around simple values trims a couple of bytes per attribute.

Can I upload a file instead of pasting?

Yes — drag and drop an .html or .htm file onto the input area, or use the Upload button. The file is read locally in your browser and never sent to a server.

How much size reduction should I expect?

Typical HTML minification saves 10–25% of file size, depending on how much whitespace and commenting the original contains. Hand-written HTML with generous indentation often shrinks the most.

Is my HTML uploaded to a server?

No. Minification runs entirely in your browser using vanilla JavaScript. Your markup — including any embedded styles, scripts, or proprietary data — never leaves your device.

Part of our growing tool belt — all client-side, all free.