What This Tool Does (And What It Does Not)
This html minifier online strips comments, collapses whitespace between tags, and collapses boolean attributes, all through targeted text-level substitutions rather than a full DOM parser. It is honest about the trade-off: unlike html-minifier-terser, which parses a real DOM tree, minifies the JavaScript and CSS sitting inside script and style tags, and can strip a much wider set of redundant attributes, this tool works on the text directly, so it is fast, predictable, and safe for a quick paste-and-go job, but it will not squeeze out every last byte the way a build-pipeline minifier can. One thing worth knowing up front: content inside script, style, pre, and textarea tags is deliberately left completely untouched, this tool will never minify javascript or css sitting in your HTML, it only cleans up the HTML markup around it.
How to Minify HTML With This Tool
Paste your HTML into the input field to minify html code online, toggle which options you want (remove comments from html, collapse whitespace, collapse boolean attributes, and three more advanced options for empty attributes, redundant attributes, and optional closing tags), and the minified output appears immediately along with the original size, the minified size, and the percentage saved. There is nothing to install and no build step to configure, so you can minify html online in the time it takes to paste and copy. Copy the result directly, it is valid HTML, just smaller.
What Gets Removed vs. What Gets Preserved
HTML comments are removed entirely when that option is on, except IE conditional comments like <!--[if IE]-->, which are left alone since they carry real logic. Whitespace between tags is collapsed, making this a genuine html whitespace remover rather than just a comment stripper, but whitespace inside pre, textarea, script, and style tags is protected first so multi-line JavaScript, CSS, or preformatted text is never touched. Boolean attributes are collapsed to their shorthand form, disabled="disabled" becomes disabled, checked="true" becomes checked, and so on for the standard HTML boolean attribute list. Three additional options, off by default, remove empty attributes like class="", strip a small set of known-redundant attributes like type="text" or charset="utf-8", and drop optional closing tags like </li> or </p> where the HTML spec allows it.
Lightweight Minifier vs. a Full Build-Tool Minifier
A lightweight, text-based html minifier free of any build step is the right choice for shrinking a standalone HTML file, cleaning up markup before pasting it into a code sample or a support ticket, or getting a quick before-and-after size comparison. A full build-tool minifier like html-minifier-terser understands the DOM well enough to also minify inline script and style content and apply a much broader set of attribute-level optimizations, which matters more once you're running a production build pipeline with webpack or a static site generator already in place.
Common Uses for an HTML Minifier
Trimming a page before pasting it into a forum post or a bug report, removing comments left over from development before sharing a file, needing to compress html file content for a static page without setting up a bundler, and comparing before-and-after byte size to see how much comments and formatting were actually costing are all common reasons to reduce html file size with an html compressor online like this one.