HTML Minifier: Compress HTML Code Online
Make HTML smaller so pages load faster, without changing how they look.
- Works on your device. Nothing is uploaded.
- Free, no watermark
- No signup
How to use
- Paste HTML or open an .html file.
- Choose whether to remove comments and minify inline CSS or JavaScript.
- Copy or download the minified HTML and check the size saved.
Good to know
Our minifier removes comments (except old Internet Explorer conditional comments), joins runs of spaces and line breaks into one space, drops whitespace between block tags and tidies spaces inside tags. It keeps one space between inline elements such as "<b>a</b> <i>b</i>", because removing it would join the words on screen.
Text inside <pre>, <textarea>, <script> and <style> is copied exactly unless you choose to minify inline CSS (with csso) or JavaScript (with terser). Script types that are not JavaScript, such as templates or JSON, are never touched.
Most servers already compress pages with gzip or Brotli, so the real saving on the network is smaller than the percentage shown here. Minifying still helps large pages and email templates. Keep your original file: minified HTML is hard to edit.
Questions
Is it safe to minify HTML?
Yes for normal pages. Inline spacing and <pre> blocks are kept. Test the page once after minifying.
Why is JavaScript minification a separate button?
It loads a larger library, so it runs only when you ask.
How much smaller will my page be?
Usually 5–25%, more if there are many comments or indented code.
Does it remove optional tags or quotes?
No. We keep tags and quotes to avoid surprises.
Is my code uploaded?
No. Everything runs in your browser.