Language
English English Vietnamese (Tiếng Việt) Vietnamese (Tiếng Việt) Chinese (简体中文) Chinese (简体中文) Portuguese (Brazil) (Português do Brasil) Portuguese (Brazil) (Português do Brasil) Spanish (Español) Spanish (Español) Indonesian (Bahasa Indonesia) Indonesian (Bahasa Indonesia)
HTML Minifier

HTML Minifier

Minify HTML markup in your browser to reduce file size. Removes comments, collapses whitespace, strips optional closing tags, and cleans up redundant attributes.

Minify HTML to Shrink Page Size

This HTML minifier compresses markup right in your browser to reduce file size. It removes comments, collapses the whitespace between tags, strips optional closing tags, and cleans up redundant attributes — producing smaller, faster-loading pages that render exactly the same. It is built for front-end developers, template authors, and anyone shipping static HTML who wants fewer bytes without adding a build step.

Runs entirely in your browser. Your markup is never uploaded or stored on a server — everything is processed locally, so even private templates stay on your machine.

Why Compress HTML

Faster Rendering

Fewer bytes mean the browser downloads and parses the document sooner, improving perceived speed.

Smaller Payloads

Trimming whitespace and comments cuts page weight, which is especially valuable on mobile networks.

No Build Step

Minify static pages, email templates, or generated markup without configuring any tooling.

How to Minify HTML

1

Paste or Upload Your HTML

Type or paste your markup into the input panel on the left, or use Upload to load an .html file. Click Sample to try it with example code.

2

Choose Your Options

Toggle Remove comments, Collapse whitespace, and Remove optional tags to control how aggressively the page is compressed.

3

Let It Minify

The output updates automatically as you edit. To minify immediately without waiting, press Ctrl + Enter in the editor.

4

Review & Export

Check the stats bar for original size, minified size, and the percentage saved. Then Copy the result or Download it as an .html file.

Shortcut: auto-minification is debounced, so heavy edits won't lag — press Ctrl + Enter to force an instant run.

Minification Options & Features

Configurable Options

Each option targets a specific source of bloat. Combine them to reach your preferred balance of size and readability.

OptionWhat It DoesDefault
Remove commentsStrips <!-- --> comments while keeping conditional commentsOn
Collapse whitespaceRemoves redundant spaces and newlines between and around tagsOn
Remove optional tagsDrops optional closing tags such as </li>, </p>, </td>Off

Smart & Safe by Default

Preserves Sensitive Tags

Content inside <pre>, <script>, <style>, and <textarea> is never touched, so formatting and code stay intact.

Strips Default Attributes

Removes redundant type="text/javascript" and type="text/css" declarations that browsers assume anyway, plus quotes around simple attribute values.

Keeps Conditional Comments

Legacy IE conditional comments (<!--[if ...]-->) are retained even when comment removal is enabled.

Live Compression Stats

View original size, minified size, and the percentage saved after every run, with syntax-highlighted output.

About optional tags: the HTML5 spec allows omitting certain closing tags. Removing them is valid and shrinks size, but disable the option if your tooling or templates expect explicit closings.

Frequently Asked Questions

Is my code sent to a server?

No. All minification happens locally in your browser. Your HTML is never uploaded, logged, or stored anywhere.

Will minifying break my HTML?

No. Minification only removes characters the browser ignores anyway. Content inside <pre>, <script>, <style>, and <textarea> is preserved, so the page renders exactly the same.

Does minifying HTML improve page speed?

Yes, modestly. Smaller HTML downloads faster and there are fewer bytes for the browser to parse. The effect stacks on top of gzip/Brotli compression, and matters most on slow or mobile connections.

What are "optional closing tags"?

In HTML5, the closing tags for certain elements — such as </li>, </p>, and </td> — are optional. Browsers infer where they belong, so removing them is valid HTML and reduces file size without affecting rendering.

How much file size can I save?

It depends on how much whitespace, indentation, and how many comments the source contains — heavily formatted or commented templates see the biggest gains. The live stats bar shows your exact savings for each run.

Can I unminify HTML?

Minification is one-way: removed comments and whitespace are gone. To make minified HTML readable again, run it through an HTML formatter or beautifier, which re-indents the markup.

Will it minify my inline JavaScript or CSS?

No. Content inside <script> and <style> tags is preserved untouched. To shrink those, run the code through the dedicated JavaScript or CSS minifier tab first.

Input
Output
Error

Paste code on the left to minify automatically

Original 0 B Minified 0 B
Saved 0%
|
Paste your HTML and edit the input; it minifies automatically as you type.
Press Ctrl+Enter to minify instantly without waiting.
Content inside <pre>, <script>, <style>, and <textarea> tags is preserved.
Enable Remove optional tags for extra savings on list- and table-heavy pages.
Want to learn more? Read documentation →
1/5
Start typing to search...
Searching...
No results found
Try searching with different keywords