HTML Minify

Minify HTML: remove comments and collapse extra whitespace while keeping <pre>, <textarea>, <script> and <style> blocks untouched, so the page still renders the same. Runs in your browser.

Suggested tools

JSON Minify

Minify / compact JSON.

JSON
Open Tool

XML Minify

Minify / compact XML.

XML
Open Tool

CSS Minify

Shrink CSS by removing comments and spaces, keeping it valid.

CSS
Open Tool

CSV to HTML

Convert CSV into an HTML table.

CSVHTML
Open Tool

HTML Escape / Unescape

Encode < > & " ' as HTML entities, or decode entities back to text.

HTML
Open Tool

HTML Formatter

Indent and tidy HTML, or minify it.

HTML
Open Tool

About HTML Minify

HTML Minifier reduces the size of HTML by removing comments and collapsing runs of spaces, tabs and line breaks, and by dropping whitespace around block-level tags where it never shows on screen.

It keeps what matters: content inside <pre> and <textarea> (where spaces are visible) and <script>/<style> blocks are left exactly as they are, the single space between inline elements like "<b>Hello</b> <i>World</i>" is preserved, and IE conditional comments are kept. Everything runs locally in your browser — the text you paste is never uploaded.

How to use HTML Minify

  1. Paste your HTML or upload a file.
  2. Press Minify.
  3. Copy or download the compact HTML.

Key features

  • Removes comments and redundant whitespace
  • Leaves <pre>, <textarea>, <script> and <style> untouched
  • Keeps meaningful spaces between inline elements
  • Safe for email templates and static pages

Example

The comment and extra spaces go; the <pre> block is left exactly as it was.

Input
<div class="card">
  <!-- price -->
  <p>  Pen  </p>
  <pre>  keep   this  </pre>
</div>
Output
<div class="card"><p>Pen</p><pre>  keep   this  </pre></div>

When to use HTML Minify

  • Making static pages and email templates smaller.
  • Compacting HTML before embedding it in JSON or a database field.
  • Removing developer comments before publishing a page.

Tips and common problems

  • Content in <pre>, <textarea>, <script> and <style> is left untouched on purpose.
  • Check the page afterwards if it relies on spaces between inline elements for layout.
  • Minify CSS separately with CSS Minifier.

Frequently asked questions

No — script and style blocks are kept as they are, to avoid breaking them. Minify CSS separately with CSS Minifier.