Digital ToolPad.

Runs 100% in your browser

Your data never leaves your device. zero uploads.

HTML Minifier

Shrink HTML for production by removing comments and extra whitespace and compressing inline CSS, without breaking pre blocks or scripts.

  • Safe whitespace collapse
  • Inline CSS minified
  • JSON-LD compacted
  • Bytes saved
611 B → 0 B (100.0% smaller)Preview runs with scripts disabled.

What is HTML minification?

HTML minification removes characters browsers do not need, such as comments, indentation and line breaks, to make pages smaller and faster to download. This minifier works conservatively: it keeps spaces between inline elements, protects pre, textarea, script and style contents, keeps IE conditional comments, minifies CSS in style blocks and style attributes and compacts JSON-LD structured data. Optional extras remove attribute quotes and tidy inline JavaScript.

How to minify HTML

  1. Paste your HTML or open a file.
  2. Choose what to remove: comments, whitespace, CSS, inline JS tidy and attribute quotes.
  3. Check the size saving and the preview.
  4. Copy or download the minified HTML.

Minification tips

  • Most servers also compress with gzip or Brotli; minifying first still saves bytes.
  • Gmail clips messages over about 102 KB, so minify long email templates.
  • Keep an unminified copy for editing.
  • For JavaScript-heavy pages, use a build tool such as esbuild or Terser for scripts.

Why use this html minifier

  • Safe by defaultInline spacing, pre, textarea and script content are preserved so the page still looks and works the same.
  • See the savingShows bytes before and after and the percentage saved.
  • Live sandboxed previewSee the rendered page next to the code, with scripts disabled for safety.
  • Code never leaves your deviceFormatting runs in your browser, so internal templates, emails and client pages are never uploaded.

Common uses

  • Static sites. Smaller HTML files for faster loading.
  • Email templates. Stay under clients’ size limits (Gmail clips at 102 KB).
  • Embedded widgets. Compact HTML snippets for other sites.
  • Performance audits. See how much minification would save.

Working with other formats? Try the XML formatter, JSON formatter and SQL formatter, convert HTML to Markdown, or compare versions with the diff checker.

Example: a template with comments

A 24 KB email template with comments and indentation typically drops to 15–18 KB after minification, before gzip.

What to expect from the result

JavaScript is only tidied (comments and blank lines removed), not fully minified or mangled. Whitespace inside inline elements is collapsed to a single space, which matches how browsers render it, except inside pre and textarea.

HTML Minifier questions

Is it safe to minify HTML?

Yes, with a careful minifier. This one keeps spaces between inline elements and never changes pre, textarea or script contents.

How much does minifying HTML save?

Usually 10–30% before gzip, more for heavily indented or commented templates.

Does it minify CSS and JavaScript?

CSS in style blocks and style attributes is minified. JavaScript is tidied by removing comments and blank lines; use a JS minifier for more.

Will minifying remove my conditional comments?

No. IE conditional comments are kept.

Is my HTML uploaded?

No. Formatting runs in your browser and nothing is sent to a server.

100% private — your data never leaves your browser

No registration, no tracking of your content, no server uploads. Don't just take our word for it:

  • No server, no uploads

    Your files and text are processed entirely on your device. Nothing is ever sent to us.

  • Works offline

    Once loaded, this tool keeps working with your Wi-Fi turned off. Try it.

  • Verify it yourself

    Open your browser's DevTools → Network tab. You'll see zero requests carrying your data.

Explore more tools

More utilities for your next task.

Browse all tools