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 code online to reduce file size. Removes comments, collapses whitespace, strips optional tags, and removes unnecessary quotes.

HTML Minifier

The HTML Minifier is a free online tool that compresses markup to reduce file size. It removes comments, collapses whitespace between tags, strips optional closing tags, and cleans up redundant attributes — producing smaller, faster-loading HTML pages without altering how they render.

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 Minify HTML

Faster Rendering

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

Smaller Payloads

Trim 10–30% off page weight to cut bandwidth, 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. Hit 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

Minify

Click Minify or press Ctrl + Enter. The compressed HTML appears instantly in the output panel.

4

Review & Export

Check the stats bar for original size, minified size, and savings. Then Copy the result or Download it as a file.

Shortcut: press Ctrl + Enter in the editor to minify instantly.

Optimizations & Features

Configurable Minification 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 like </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.

Keeps Conditional Comments

Legacy IE conditional comments are retained even when comment removal is enabled.

Compression Stats

View original size, minified size, and the percentage saved after every run.

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 minification break my HTML?

No. The minifier preserves content inside <pre>, <script>, <style>, and <textarea> tags. It only removes whitespace and comments from the rest of the document, so the page renders exactly the same.

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 reduction can I expect?

Typical pages shrink by 10–30%, depending on how much whitespace, indentation, and how many comments the source contains. Heavily formatted or commented templates see the biggest gains.

Will it remove 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 first.

Input
Output
Error

Paste code on the left to minify automatically

Original 0 B Minified 0 B
Saved 0%
|
Paste your HTML code and click Minify to compress it.
Use Ctrl+Enter to minify quickly.
Content inside <pre>, <script>, <style>, and <textarea> tags is preserved.
Want to learn more? Read documentation →
1/4
Can't find it? Build your own tool with AI
Start typing to search...
Searching...
No results found
Try searching with different keywords