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.
Why Minify HTML
Faster Rendering
Smaller Payloads
No Build Step
How to Minify HTML
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.
Choose Your Options
Toggle Remove comments, Collapse whitespace, and Remove optional tags to control how aggressively the page is compressed.
Minify
Click Minify or press Ctrl + Enter. The compressed HTML appears instantly in the output panel.
Review & Export
Check the stats bar for original size, minified size, and savings. Then Copy the result or Download it as a file.
Optimizations & Features
Configurable Minification Options
Each option targets a specific source of bloat. Combine them to reach your preferred balance of size and readability.
| Option | What It Does | Default |
|---|---|---|
| Remove comments | Strips <!-- --> comments while keeping conditional comments | On |
| Collapse whitespace | Removes redundant spaces and newlines between and around tags | On |
| Remove optional tags | Drops 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.
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.
No comments yet. Be the first to comment!