HTML Minifier
Strips HTML comments and collapses whitespace between tags. Content inside <script>, <style>, <pre> and <textarea> is left exactly as-is, since whitespace there can be meaningful.
What this does and doesn't do
This is a safe, conservative minifier — it removes comments and extra whitespace but never touches the content of scripts, styles, or preformatted text. It won't shrink your file as aggressively as a full build-tool minifier (like html-minifier-terser used in Webpack/Vite pipelines), but it also won't risk breaking your page. Always preview the result before deploying it.
How to use the HTML Minifier: step by step
- Paste your HTML.
- See the original size, minified size and saving.
- Copy the minified HTML.
- Check the page still looks right.
A real example
An email template has comments and indentation that make it larger than some email clients like. Minifying removes them while leaving the content untouched.
Tips for better results
- Content inside
<script>,<style>,<pre>and<textarea>is left exactly as it is. - Most servers already compress HTML (gzip or Brotli), so minifying gives smaller extra gains.
- Keep the original for editing.
More questions
Will it change how my page looks?
It shouldn’t, because whitespace in sensitive tags is preserved. Check once anyway.
Does it minify inline CSS and JS?
No, use the CSS and JavaScript minifiers for those.
Frequently asked questions
Is minifying HTML worth it?
The gain is modest if your host already compresses files with gzip or Brotli, but it still trims bytes on large pages.
Will it break my inline scripts?
No. Content inside <script>, <style>, <pre> and <textarea> is left exactly as written.
Are conditional comments kept?
Ordinary comments are removed. Keep a copy of your original file for editing later.