HTML Minifier
HTML Minifier removes unnecessary whitespace, comments and optional characters from HTML. The result is smaller and faster to transfer, which matters for page speed.
Share this page:
HTML Minifier removes unnecessary whitespace, comments and optional characters from HTML. The result is smaller and faster to transfer, which matters for page speed.
HTML Minifier at a glance
- Shrink a static HTML page before uploading it to a host.
- Reduce the size of an email template where whitespace is not needed.
- Compare the before and after size when optimising a page.
Step by step
- Paste HTML into the input box or upload an HTML file.
- Click Minify to produce the compact output.
- Copy the minified markup or save it for deployment.
Accuracy, limits and privacy
Keep the readable source in version control. Minify as a build step rather than editing the minified file by hand.
How it works in practice
Whitespace is significant inside inline elements and preformatted blocks. Minify a copy, then compare the rendered page at desktop and mobile widths before deploying.
Where people go wrong
- Minifying a template that relies on spaces between inline elements.
- Editing the minified file and losing the readable source.
Common questions
Can minifying break the page?
Whitespace can be significant inside inline elements, preformatted blocks and some templates. Test the minified output before deploying it.
Does it remove comments?
It typically strips comments to save bytes. Keep a copy of the source if comments are part of your documentation.
How much smaller will the file be?
It depends on how much whitespace and commenting the source contains. Hand-written HTML often shrinks more than already-compact output.
Related Tools
More free tools you may like