HTML Minifier
Compress HTML by removing safe whitespace and comments.
HTML Minifier
Developer tool running locally in browser
What does HTML Minifier do?
Reduce HTML size by collapsing whitespace between block elements and stripping comments, while leaving pre, textarea, script and style content untouched. The byte saving is reported so you can judge the benefit.
How to Use HTML Minifier
- 1Paste your HTMLA full page or a fragment.
- 2Set the optionsChoose whether to strip comments.
- 3Copy the minified HTMLThe saving is shown above it.
Key Features
- Collapses whitespace only where it is not rendered
- Removes comments, with an option to keep conditional comments
- pre, textarea, script and style content untouched
- Original and minified sizes with the percentage saved
- Estimated gzip size so you can see the real network benefit
Frequently Asked Questions
How much does minifying HTML save?
Typically 5–20% before compression, and considerably less after gzip, which already collapses repeated whitespace efficiently. It is a small optimisation, not a transformative one.
Is minifying HTML risky?
It can be if done naively, because whitespace between inline elements is rendered. This minifier only collapses whitespace in positions where it has no visual effect, and leaves preformatted content alone.
Should I remove comments?
Usually yes in production. Keep conditional comments if you still support very old Internet Explorer, and keep any comment your build or CMS relies on as a marker.
Should I minify by hand or in my build?
In your build. Minifying by hand means your source and deployed files diverge, which makes debugging harder. Use this tool for one-off files and inspection.
Input is processed in your browser and never transmitted. That said, treat any web page as untrusted for live production secrets — rotate anything you paste anywhere.
Related Tools
HTML Formatter
Beautify or minify HTML with correct indentation.
CSS Minifier
Compress CSS by stripping whitespace and comments.
JSON Minifier
Strip whitespace from JSON to make it as small as possible.
SQL Minifier
Collapse a SQL query onto a single compact line.
