HTML Minifier

Shrink HTML for production by stripping unnecessary whitespace, line breaks, and comments — right in your browser. Paste or upload markup and get a compact, byte-saving version instantly.

100% Client-Side Processing

Your HTML is parsed and minified entirely in your browser. Nothing is uploaded to a server.

Live preview

The preview runs in a sandboxed frame with scripts disabled, so pasted <script> tags are shown but never executed.

Minified HTML
Lines: 0 Size: 0 chars

What is an HTML Minifier?

An HTML minifier strips out everything a browser doesn't need to render your page correctly — redundant whitespace, line breaks, and, optionally, comments — so the same markup ships in fewer bytes. It's a quick way to shave file size off static pages, email templates, or any HTML you serve directly to visitors.

This tool parses your HTML with the browser's own built-in parser — the same engine that renders web pages — so it handles real-world, imperfect markup (unclosed tags, mixed casing, missing quotes) exactly the way a browser would, then compacts it from that corrected structure.

How it Works

  • Add your HTML: Paste HTML directly into the editor, or upload an .html file.
  • Choose whether to strip comments: Toggle "Strip HTML comments" on if you don't need them in the shipped output.
  • Review instantly: Your minified HTML, a live sandboxed preview, and size-reduction stats update as you type.
  • Copy or download: Copy the result to your clipboard or download it as an .html file.

Features

  • Paste HTML or upload an .html file
  • Instant minification that strips redundant whitespace and line breaks
  • Optional HTML comment stripping
  • Preserves <pre>, <script>, <style>, and <textarea> content exactly
  • Keeps a single space between words so text never runs together
  • Live sandboxed preview so you can confirm nothing changed visually
  • Output size and size-reduction percentage stats
  • Copy to clipboard or download as .html
  • 100% client-side processing for privacy

Best Practices

  • Minify only your shipped output: keep a readable, formatted source file and minify as a build step, not the file you edit day to day.
  • Check the preview after minifying: confirm the rendered page still looks identical, especially around whitespace-sensitive inline text.
  • Strip comments only when you're done debugging: comments often carry context for the next person to touch the file, so keep them in your source and strip them only in the minified build.
  • Pair it with other production optimizations: minifying HTML shrinks markup, but combine it with CSS/JS minification and image compression for the biggest page-weight wins.
  • Keep a beautifier handy for review: minified output isn't meant for editing — use the HTML Beautifier whenever you need to inspect or debug it.

Troubleshooting

The minified output looks like one long line

That's expected — minifying removes line breaks and whitespace between tags to save bytes. Content inside <pre>, <script>, <style>, and <textarea> is left untouched since whitespace there is often meaningful.

Minified output still contains some whitespace

A single space is kept between words inside a line of text so words don't run together — only redundant whitespace between tags and repeated spaces are removed.

Attribute order or quoting changed

Attributes are re-serialized in their parsed order, and boolean attributes like disabled are written without a value. This doesn't affect rendering, but it can change a text diff.

I need to read or edit my HTML, not shrink it

This tool is minify-only. For clean, indented HTML you can actually read and edit, use the HTML Beautifier or the HTML Formatter (which supports both beautify and minify modes).

Common Use Cases

  • Shrinking page weight before deploying: minify static HTML templates or landing pages to reduce transfer size and speed up first paint.
  • Compressing HTML email templates: many email clients count every byte before clipping a message — stripping whitespace and comments keeps templates under size limits without changing how they render.
  • Production build steps: minify shipped HTML output as part of a deploy pipeline while keeping a readable source file for editing.
  • Reducing bandwidth for high-traffic static sites: smaller HTML responses add up quickly at scale, cutting hosting and CDN transfer costs.
  • Preparing HTML for CDN or edge caching: a smaller cached response means faster delivery to every visitor it serves.

Frequently Asked Questions

Will JavaScript in my HTML run?

No. The live preview renders inside a sandboxed iframe with scripts disabled, so pasted <script> tags are shown but never executed.

Does minifying change how my page renders?

No. Minifying only removes whitespace, line breaks, and optionally comments — the actual markup structure and visible output stay the same.

Can it fix broken or invalid HTML?

It uses the browser's built-in parser, which automatically corrects common issues like unclosed tags, so the output is always valid — but it won't flag or explain what was fixed.

What happens to content inside <pre>, <script>, <style>, and <textarea>?

It's preserved exactly as-is, since whitespace inside those elements is often significant.

Does it remove HTML comments?

Only if you turn on the "Strip HTML comments" option — by default, comments are kept.

Does this tool also beautify HTML?

No, this tool only minifies. If you need clean, indented HTML for editing or review, use the HTML Beautifier, or the HTML Formatter, which supports both modes.

Do you store my HTML?

No. Everything happens locally in your browser, and nothing is uploaded or saved.

Share this tool

Share a direct link or embed this tool on your site. Keep the Tooladex attribution link to support the project.