HTML Minifier
Strip comments and extra whitespace from HTML markup to produce a smaller file.
How to use the html minifier
- Paste your HTML into the input box.
- Click Minify.
- Copy or download the compressed result.
Features
- Removes HTML comments
- Collapses whitespace between tags
- Copy or download as a ready-to-use .html file
Use minified HTML safely
HTML minification removes redundant whitespace and comments while keeping the document structure. It can reduce transfer size slightly, especially on large generated pages, but compression such as Brotli or gzip usually provides the larger network saving.
Whitespace can be meaningful inside preformatted text, templates and some inline content. Keep the original source and verify pages that contain code samples, email templates or JavaScript-driven markup before deploying the minified version.
Minification should be the final delivery step, not the editing format. Readable source makes accessibility checks, debugging and code review much easier, while the smaller copy can be generated whenever you publish.
If a page is generated by a framework or template system, it is usually safer to minify the final generated HTML rather than editing a minified template by hand.
Frequently asked questions
tags.
Related tools
Protect your editable source
HTML minification is a delivery optimisation, not a replacement for clean source code. Keep the original markup in version control because compressed output is inconvenient to review and maintain.
- Validate important pages after minification.
- Be careful with whitespace-sensitive inline content.
- Combine minification with caching and compression rather than expecting large gains from whitespace removal alone.
Related reading: What “runs in your browser” means for privacy