HTML Minifier
Remove HTML comments and collapse whitespace for smaller HTML files — browser-only, no uploads.
HTML Input
How to minify HTML
- Paste your HTML code into the input area.
- Click Minify HTML.
- Copy the minified output — the size savings are shown above the result.
Privacy — processed in your browser
Minification runs entirely in your browser using JavaScript string processing. Your code never leaves your device — no server call, no data collection.
Frequently Asked Questions
What does HTML minification remove?
HTML comments (<!-- ... -->), whitespace between tags, and leading/trailing space on lines. Content inside <pre>, <script>, <style>, and <textarea> is protected and left unchanged.
Will it break my inline CSS or JavaScript?
Inline <script> and <style> blocks are protected and passed through unchanged. Inline event handlers (onclick="...") are also preserved.
Is this a lossless operation?
For most HTML yes — removing inter-tag whitespace and comments does not affect rendering. Exceptions: whitespace-sensitive elements like inline text with spaces between tags may render slightly differently.
For production use, what should I use?
For a full production pipeline, tools like html-minifier-terser (npm) offer more aggressive optimisation including attribute quote removal and boolean attribute shortening. This tool is ideal for quick manual minification.