HTML Minifier: Compress HTML and Reduce Page Size Online
Remove comments and extra whitespace from HTML, and optionally minify inline CSS and JavaScript. See the size saved. Runs in your browser.
Paste your HTML and press Minify. Comments and extra whitespace go, the spaces that matter between inline tags stay, and you can also compress inline CSS and JavaScript. The page shows the bytes saved.
What it does
- Removes HTML comments (conditional comments are kept).
- Collapses runs of spaces and line breaks.
- Removes whitespace between block tags where it has no effect.
- Leaves pre and textarea content untouched.
- Optionally minifies inline CSS and JavaScript.
This is a safe whitespace-and-comment minifier. It does not remove optional tags or attribute quotes.
Example
Before
<!DOCTYPE html>
<html><head><title>My page</title>
<!-- styles -->
<style>body{margin:0}</style></head>
<body><div class="box"><h1>Hello</h1><p>Some <b>bold</b> text.</p><ul><li>One</li><li>Two</li></ul></div></body></html>After
<!DOCTYPE html><html><head><title>My page</title><style>body{margin:0}</style></head><body><div class="box"><h1>Hello</h1><p>Some <b>bold</b> text.</p><ul><li>One</li><li>Two</li></ul></div></body></html>Frequently asked questions
- Is it safe for my page?
- It keeps the single spaces between inline elements and does not touch pre or textarea. Check the page after minifying, as with any minifier.
- Does it remove quotes or optional tags?
- No. Attribute quotes and optional closing tags stay, which keeps the result safe for every browser.
- What about inline JavaScript?
- Inline scripts are minified with a light method that removes comments and extra spaces. It does not rename variables.
- Will it break inline event handlers?
- No. Attribute values are not changed.
More tools
Code formatters
CSS beautifier CSS minifier HTML beautifier JavaScript beautifier JavaScript minifier JSON formatter YAML formatter XML formatter SQL formatter Markdown preview
Converters
Base64 encoder and decoder URL encoder and decoder Unix timestamp converter CSV to JSON JSON to CSV HTML entity encoder and decoder Number base converter Time zone converter JSON to TypeScript XML to JSON HTML to Markdown Date difference calculator
Text tools
Regex tester Remove duplicate lines Lorem ipsum generator Word counter Case converter Text diff checker
Color and images
Color converter Contrast checker Image to Base64 Image resizer
Network
Subnet calculator Download time calculator Common ports list CIDR to IP range IPv6 address expander and compressor MAC address formatter curl command builder
Server and files
Cron expression explainer chmod calculator HTTP status codes
Encoding and security
Password generator UUID generator Hash generator JWT decoder QR code generator Password strength checker Wi-Fi QR code generator