HTML Formatter
Pretty-print HTML with consistent indentation, or collapse it back down.
Strip the whitespace and comments out of HTML.
HTML Minifier removes what a browser does not need: comments, the whitespace between tags, and the indentation that made the file readable. The result is the same page in fewer bytes.
Whitespace in HTML is not always insignificant, and this is where careless minifiers break pages. A space between two inline elements is rendered as a space, so removing it closes the gap between two words. Content inside pre and textarea is displayed exactly as written. The tool preserves both, which means the saving is slightly smaller and the page still looks right.
The size comparison shows bytes before and after and the percentage saved. It is worth being realistic about the benefit: once your server applies gzip or brotli compression, repeated whitespace compresses to almost nothing anyway, so minifying HTML typically saves a few percent of the transferred size rather than the headline figure. It is still worth doing in a build; it is not worth breaking a page for.
The html minifier is used by writers, developers, students, marketers and anyone else who needs the job done once without installing software. Common cases include:
It can, if whitespace that affects rendering is removed. This tool preserves spaces between inline elements and the contents of pre and textarea for exactly that reason. Always compare the rendered output before and after.
Before compression, often twenty to forty percent. After gzip or brotli, usually only a few percent, because repeated whitespace compresses extremely well. Minify in your build if it is free; do not treat it as a major performance win.
By default yes, with an option to keep conditional comments, which some legacy email clients still act on.
It drops the quotation marks around attribute values that do not need them. It is valid HTML and saves a few bytes, but it makes the markup harder to read and harder to edit by hand, so it is off by default.
Use the HTML Formatter to indent it again. Comments that were removed cannot be recovered.
No. Minification runs in your browser.
If the html minifier is not quite what you need, these other free tools solve closely related problems.
Pretty-print HTML with consistent indentation, or collapse it back down.
Minify CSS by removing comments, whitespace and redundant characters.
Shrink JavaScript by removing comments and whitespace, without renaming anything.
Compress and resize JPEG, PNG and WebP images privately in your browser.
A three-pane editor with a live preview that updates as you type.