About the HTML Minifier tool
Every byte of HTML has to travel to the visitor before the browser can start rendering, and hand-written or template-generated markup is full of indentation, blank lines and developer comments that nobody sees. Removing them makes pages lighter, which helps load time on slow mobile connections and trims bandwidth for high-traffic sites and HTML emails.
This HTML minifier scans your document tag by tag. It deletes ordinary comments while keeping Internet Explorer conditional comments, collapses runs of whitespace in text to a single space and tidies the spacing inside tags without touching quoted attribute values. The contents of <pre> and <textarea> are copied exactly, because whitespace there is visible. Inline <style> blocks are passed through a CSS minifier, inline <script> blocks through a comment-and-whitespace JavaScript minifier, and, with that option on, JSON-LD structured data is re-serialised compactly when it is valid JSON.
A size panel shows the original bytes, the minified bytes, the percentage saved and the gzipped size of both versions, so you can see the real-world gain after server compression. Everything runs locally in your browser, so private templates are never uploaded.
How to use HTML Minifier
- Paste your HTML into “HTML input”, click “Open file” to load an .html file, or press “Load sample”.
- Choose the options: “Remove comments”, “Collapse whitespace”, “Remove spaces between tags”, “Minify inline CSS” and “Minify inline JS”.
- Read the size tiles to see the original size, minified size, percentage saved and gzipped size.
- Check the “Minified HTML” pane, then click “Copy” or “Download” to save the .min.html file.
Features
Safe for pre and textarea
Whitespace-sensitive <pre> and <textarea> content is copied byte for byte.
Inline CSS and JS minified
Style blocks and JavaScript script blocks are compressed too, while template scripts are left alone.
Attribute values untouched
Spacing inside tags is tidied but quoted attribute values keep every character.
Real savings numbers
See byte and gzip sizes before and after, calculated with your browser’s own compression stream.
Conditional comments kept
<!--[if IE]> blocks survive so legacy email and browser hacks keep working.
When to use it
- Shrink a static landing page before uploading it to a CDN or S3 bucket.
- Reduce the size of an HTML email so Gmail does not clip it at 102 KB.
- Compress exported HTML from a page builder that adds heavy indentation.
- Check how much a template would gain from minification before adding a build step.
- Strip internal developer comments before handing HTML to a client.
Frequently asked questions
Will minifying HTML break my page?
Normally no. Comments and repeated whitespace have no effect on rendering, and <pre>, <textarea>, script and style content is protected. The one option to review is “Remove spaces between tags”, because a space between two inline elements like links can be visible.
Does it minify the JavaScript inside script tags?
Yes, when “Minify inline JS” is on. It removes comments and whitespace only and never renames variables. Scripts with a non-JavaScript type, such as text/template, are kept as they are.
How much smaller will my HTML get?
Typically 10–30% for hand-written pages, more for heavily indented templates. Because servers usually gzip HTML, the gzipped size tile shows the saving that actually reaches visitors.
Is my HTML uploaded to a server?
No. The minifier runs entirely in JavaScript in your browser tab, so your markup never leaves your device.
Does it remove optional closing tags or attribute quotes?
No. This tool keeps your markup structure intact and focuses on comments and whitespace, which is the safest kind of HTML minification.