HTML Minifier
Make HTML pages and email templates smaller without breaking them. Comments and spacing that browsers ignore are removed, and the CSS and JavaScript inside the page are minified too.
How to minify HTML
- 1Paste your HTML or open an .html file.
- 2Choose whether to remove comments and minify inline code.
- 3Copy the minified HTML or download it.
Careful with spacing
Runs of spaces and line breaks become one space, and spacing between block elements like <div> and <p> is removed. A single space between inline elements stays, so words never run together, and <pre> and <textarea> are left exactly as they are.
Inline code
<style> blocks are minified with CSSO and <script> blocks with Terser. JSON-LD and other JSON scripts are compacted, and scripts of unknown types are left alone.
Small extras
Boolean attributes are shortened (checked="checked" becomes checked), default type attributes on scripts and styles are dropped, and Internet Explorer's conditional comments are kept.
Frequently asked questions
- Is my code uploaded?
- No. Everything runs in your browser, so your code never leaves your device.
- Will my page look different?
- It shouldn't. Only spacing that browsers ignore is removed. Check the result once, especially pages that rely on whitespace between inline-block elements.
- Should I still use gzip or Brotli?
- Yes. Minifying and compression work together; most hosts compress HTML automatically.