HTML Minifier (Compress HTML)
How to Use
Paste HTML and the tool emits a compressed version with whitespace, newlines, and comments removed. The contents of `<pre>`, `<script>`, `<style>`, and `<textarea>` are preserved by default so embedded code and pre-formatted text aren't damaged. Original / minified sizes and the savings percentage are shown.
What HTML Minification Does
Indented HTML is readable but wastes bytes on the wire. **Minifying at build time reduces transfer size** without changing rendering. This tool stays on the safe side — it doesn't strip quote marks from attributes or aggressively rewrite content. For production builds with full optimization (attribute quote elision, entity normalization, etc.), use `html-minifier-terser`.
Use Cases
- Reducing HTML size before deploying a static site
- Compacting email templates (less work for email clients)
- Compressing template-engine output (EJS, Handlebars, etc.)
- Inlining HTML into data attributes without bloat
- Reducing complex HTML to a single line for logging
Privacy
Minification happens entirely in the browser; the HTML never leaves your device. Safe for internal templates or content with personal data.
FAQ
How is this different from a full minifier like html-minifier-terser?
This tool stays on the safe side: it collapses whitespace, removes newlines, and strips comments, but it does not remove attribute quotes or aggressively rewrite content. For maximum production optimization (quote elision, entity normalization), use html-minifier-terser in your build.
Is it safe to minify internal templates or HTML with personal data?
Yes. Minification runs entirely in your browser and the HTML never leaves your device — no upload, logging, or storage. Internal templates and content with personal data stay local.
Does it break embedded JavaScript, CSS, or pre-formatted text?
No. By default the contents of <pre>, <script>, <style>, and <textarea> are preserved, so embedded code and whitespace-sensitive text are not damaged. You can toggle this preservation off if you want.
Can I choose what gets removed?
Yes. You can independently toggle collapsing consecutive whitespace and removing HTML comments, plus the option to preserve the sensitive blocks above.
How much smaller will my HTML get?
It depends on how much indentation and how many comments your source has. The tool displays the original size, the minified size, and the savings percentage so you can see the exact impact for your input.