HTML Minifier
Minify HTML by stripping whitespace, comments, and unnecessary formatting. Copy or download the result without sending data anywhere.
HTML Minifier
This HTML Minifier removes unnecessary whitespace, comments, optional tags, and redundant attributes from HTML documents to produce the most compact representation. It reduces page weight for faster load times and lower bandwidth usage.
The minification runs entirely in your browser using the html-minifier library. Your HTML code never leaves your device, making it safe for processing production templates, email HTML, or any markup containing sensitive content.
How to use
- Paste your formatted or pretty-printed HTML into the input editor.
- Click Minify HTML to strip whitespace and comments.
- View the compact HTML in the output editor.
- Use Copy for the clipboard, Download for a .html file, or Clear to reset both editors.
What is HTML minification?
HTML minification is the process of removing all characters from an HTML document that are not required for correct rendering. This includes stripping whitespace between tags, removing HTML comments, collapsing redundant whitespace in attributes, and optionally removing optional closing tags.
Minified HTML is a standard practice in web performance optimization. Search engines and browsers do not require formatted HTML, so minifying production markup can reduce page size by 10-20% or more, leading to faster downloads and improved page speed scores.
Input notes
The tool accepts any HTML input. It collapses whitespace between tags, removes comments, and applies safe minification options that preserve correct rendering. Inline JavaScript and CSS within the HTML are also minified.
Example
Formatted HTML is compressed by removing whitespace and comments:
--- Input (formatted) --- <div class="card"> <!-- Card content --> <h2>Title</h2> <p>Description</p> </div> --- Output (minified) --- <div class="card"><h2>Title</h2><p>Description</p></div>