HTML Minify
Strip comments and unnecessary whitespace from HTML, live as you type.
<!doctype html><html><head><title>Page</title></head><body><h1>Hello</h1></body></html>Strips comments and collapses whitespace live as you type. If your markup relies on preserved whitespace inside a <pre> or <textarea>, check the output — this tool collapses that too rather than special-casing those elements. Runs entirely in your browser.
Need the opposite? HTML Prettifier
What is HTML Minify?
Paste HTML and get it minified instantly: comments and inter-tag whitespace stripped, output shrunk for production without changing the rendered result. Smaller HTML means fewer bytes over the wire on first load, which matters most on a mobile connection or a page with a lot of markup. Minification runs entirely in your browser, so the source never has to be uploaded to a third-party service.
How to Use HTML Minify
- 1
Paste the HTML: Enter any HTML, including comments and indentation.
- 2
Read the Minified Result Instantly: The minified markup appears automatically as you type.
- 3
Copy the Result: Use the copy button to copy the minified HTML for production.
How It Works
HTML comments (`<!-- ... -->`) are stripped, and whitespace between tags (indentation, line breaks, blank lines used purely for readability) is collapsed. Tags, attributes, and text content are left as-is, so the page renders identically; only the formatting whitespace around it is removed.
Example
<div>
<!-- main heading -->
<h1>
Welcome
</h1>
<p>Hello world</p>
</div><div><h1> Welcome </h1><p>Hello world</p></div>The comment and all inter-tag whitespace are gone; the rendered page is identical.
Common Use Cases
Shrinking a static page's markup before deploying it to production, reducing bytes transferred on first load.
Compressing an HTML snippet meant to be embedded in an email template or a CMS field with limited size.
Frequently Asked Questions
Common questions about HTML Minify.