Lighter HTML, Quicker First Paint
When someone opens your page, the HTML is the very first file their browser asks for. Nothing else can start until it arrives: no styles, no images, no scripts. That makes the size of your HTML more important than it first appears. Every tab, blank line and forgotten comment is a few more bytes standing between your visitor and the moment something shows up on screen.
An HTML minifier trims that excess while leaving the page looking and working exactly the same. Paste your markup into the box above and the compressed version appears on the right straight away, together with the number of bytes you have saved. Everything runs inside your own browser, so your code is never uploaded, logged or shared.
How to Use the HTML Minifier
- Paste your HTML into the Input HTML box. You can also open an .html file, or simply drag one onto the box.
- The minified result appears instantly on the right.
- Look at the Size Savings panel to compare the original size, the new size and the gzipped size.
- Click Copy to grab the result, or Save to download it as a .min.html file.
- Need readable code instead? Switch the output to Beautify.
What Gets Removed
- Extra whitespace. Indentation and blank lines between tags are removed, and runs of spaces inside text are reduced to one, which is exactly how the browser displays them anyway.
- Comments. Developer notes are stripped out. Conditional comments for old versions of Internet Explorer and comments that start with
<!--!are kept, because they can still matter. - Untidy attributes. Extra spaces inside tags and class lists are tidied, and self-closing slashes on elements like
<br />are dropped where HTML doesn't need them. - Long boolean attributes.
checked="checked"becomes simplychecked, which means the same thing. - Default types.
type="text/javascript"on scripts andtype="text/css"on styles are removed, since browsers assume them anyway. - Bloated inline code. CSS inside
<style>tags and style attributes is compressed with the same engine used in the CSS Minifier, and JSON-LD structured data is packed onto a single line.
There is also an optional setting that removes quotes around simple attribute values, such as class=card. This is valid HTML, but it is switched off by default because some tools and templates expect quotes.
Built Not to Break Your Page
The tricky part of minifying HTML is knowing where whitespace matters. Between two block elements, like a closing </div> and the next opening one, spaces are invisible, so they can go. Between two inline elements, like two links or two bold words, a single space is what keeps them from running together, so it is kept.
Some elements are never touched at all. Content inside <pre> and <textarea> keeps every space and line break exactly as you wrote it. JavaScript inside <script> tags is left as it is, apart from trimming the blank lines around it, because rewriting code safely needs a dedicated JavaScript tool. Attribute values containing characters like > are read correctly instead of cutting the tag short.
Before release, the tool was tested on real pages, including this one. Each page was loaded by a browser before and after minifying, and the structure of every element, every attribute and all of the visible text matched.
Beautify: Make Messy HTML Readable
Minified code is hard for people to read, and plenty of pages arrive that way. Maybe you are studying how a site is built, or cleaning up an export from a page builder. Switch to Beautify and the tool lays the markup out with consistent two-space indentation.
Block elements each get their own line, while short items such as a list item or a heading stay on a single line, so the result is neat without being stretched out. Inline CSS is formatted with one property per line, and JSON-LD is expanded into an indented, readable structure.
How Much Will You Save?
Most hand-written pages shrink by somewhere between 10 and 25 percent. Pages with heavy indentation, lots of comments or large blocks of inline CSS often save even more. Your web server probably compresses files with gzip or Brotli as well, and that already makes text much smaller during transfer. Minifying first still helps: there is simply less to compress, and the browser has fewer characters to read through once the file arrives. The gzipped figure in the Size Savings panel shows what visitors actually download.
Static sites, landing pages and email templates benefit the most, since there is often no build step doing this for you. It also helps when a blogging platform or page builder limits how much HTML you can paste.
Good Habits When Minifying
- Always keep your original, readable file and treat the minified copy as the one you publish.
- Open the page in a browser after minifying, especially if it uses unusual inline scripts or a templating language.
- Minify your CSS and JavaScript files separately with dedicated tools, then minify the HTML that links to them.
- Leave template tags such as
{{ }}or PHP code untouched by testing on a copy first.