HTML Minifier
Strip the bytes browsers do not need from your HTML. Comments and redundant whitespace are removed, inline styles and scripts are compressed, and you see how much was saved.
- Runs in your browser
- No sign-up
- Free to use
How to use HTML Minifier
- Paste your HTML or open an .html file.
- Tick the optimisations you want. The defaults are safe for almost every page.
- Select Minify HTML.
- Check the size reduction, then copy or download the minified markup.
HTML Minifier features
Whitespace collapsing
Runs of spaces and line breaks are reduced without changing how inline text is spaced.
Comment removal
HTML comments are stripped, while conditional comments are kept.
Inline CSS and JS minified
Code inside style and script elements is compressed as well.
Optional aggressive modes
Remove optional attribute quotes and redundant attributes for extra savings.
Size report
Shows the before and after size and the percentage saved.
Local processing
Templates and markup are not uploaded.
When to use HTML Minifier
- Reducing the size of a static landing page before deploying it.
- Shrinking HTML email templates to stay under clipping limits.
- Compressing an HTML snippet embedded in JavaScript or JSON.
- Squeezing a single-file demo or widget.
HTML Minifier FAQ
How much does minifying HTML save?
Typically 10–25% of the HTML file, more if it contains many comments or large inline scripts and styles. With gzip or Brotli enabled on the server, the additional saving is smaller but still worthwhile.
Can minification break my page?
The default options are conservative. Problems arise mainly where whitespace is meaningful, such as inline-block layouts that rely on gaps between elements, or pre-formatted text, which the minifier leaves alone. Test the output if you enable the aggressive options.
Is it safe to remove attribute quotes?
HTML allows unquoted attribute values when they contain no spaces or special characters, and the minifier only removes quotes in those cases. Some templating systems and XML-based tools expect quotes, so the option is off by default.
Does it handle template tags?
Server-side template syntax may be altered or cause errors. Minify the rendered HTML rather than the template source.
Should I minify HTML by hand?
For a production site, build minification into your deployment process. This tool suits one-off files, emails and quick checks.
What HTML minification removes
HTML written for people contains a lot that browsers ignore: indentation, line breaks between tags, comments explaining the markup. Minification deletes those. It can also apply rules from the HTML specification that permit shorter forms, such as dropping quotes around simple attribute values or omitting attributes whose value is the default.
The gain per file is modest compared with images, but HTML is on the critical path: the browser cannot start fetching anything else until it has received the document. Fewer bytes mean the first packets carry more of the page, which helps the earliest moments of loading, particularly on slow mobile connections.