HTML Minifier
Shrink HTML by collapsing whitespace and removing comments, while leaving pre, textarea, script and style content alone. Inline CSS is minified too.
How to minify HTML
Paste your HTML
A whole page or a fragment.
Choose the options
Remove comments, and minify CSS inside style tags.
pre and textarea are kept exactly, and scripts are left alone.
Copy or download
Use the compact HTML in production.
Worked example
This is what HTML Minifier gives for its own sample values. Open the tool above and change anything to try your own.
HTML
<!doctype html>
<html lang="en">
<head>
<title> Example </title>
<style>
body { margin: 0; }
</style>
</head>
<body>
<!-- main content -->
<p>Hello <b>world</b>,
how are you?</p>
</body>
</html>- Remove comments
- Yes
- Minify CSS in <style> tags
- Yes
Minified
<!doctype html><html lang="en"><head><title>Example</title><style>body{margin:0}</style></head><body><p>Hello <b>world</b>, how are you?</p></body></html>About HTML Minifier
Shrink HTML by collapsing whitespace and removing comments. The contents of pre and textarea are kept exactly, scripts are left alone, and CSS inside style tags is minified. A space is kept between inline elements so words do not run together.
FAQs
Does it remove optional tags or quotes?
No. The markup stays complete and valid.
Are conditional comments kept?
Yes. Comments such as <!--[if IE]> are kept.
Can I tidy HTML instead?
Use HTML Formatter & Minifier.