HTML Minifier

Strip the whitespace and comments out of HTML.

Code Formatters Free, no sign-up Runs in your browser

HTML Minifier tool

Options

About the HTML Minifier

HTML Minifier removes what a browser does not need: comments, the whitespace between tags, and the indentation that made the file readable. The result is the same page in fewer bytes.

Whitespace in HTML is not always insignificant, and this is where careless minifiers break pages. A space between two inline elements is rendered as a space, so removing it closes the gap between two words. Content inside pre and textarea is displayed exactly as written. The tool preserves both, which means the saving is slightly smaller and the page still looks right.

The size comparison shows bytes before and after and the percentage saved. It is worth being realistic about the benefit: once your server applies gzip or brotli compression, repeated whitespace compresses to almost nothing anyway, so minifying HTML typically saves a few percent of the transferred size rather than the headline figure. It is still worth doing in a build; it is not worth breaking a page for.

How to use the HTML Minifier

  1. Paste your HTMLA full page or a fragment.
  2. Choose what to removeComments, whitespace between tags, and optional quote removal.
  3. Press MinifyThe compact version appears with the size comparison.
  4. Copy or downloadTake the minified markup.

Features

  • Removes comments, with an option to keep conditional ones
  • Collapses whitespace between block-level tags
  • Preserves pre, textarea, script and style content
  • Keeps meaningful spaces between inline elements
  • Optional removal of redundant attribute quotes
  • Shows original size, minified size and percentage saved
  • Copy or download the result

Who uses this tool

The html minifier is used by writers, developers, students, marketers and anyone else who needs the job done once without installing software. Common cases include:

  • Shrinking a page before deploying it
  • Reducing the size of an HTML email template
  • Compressing a fragment embedded in a script
  • Measuring how much whitespace a template carries
  • Preparing a single-file HTML document

Frequently asked questions

Can minifying HTML break my page?

It can, if whitespace that affects rendering is removed. This tool preserves spaces between inline elements and the contents of pre and textarea for exactly that reason. Always compare the rendered output before and after.

How much will I actually save?

Before compression, often twenty to forty percent. After gzip or brotli, usually only a few percent, because repeated whitespace compresses extremely well. Minify in your build if it is free; do not treat it as a major performance win.

Are comments always removed?

By default yes, with an option to keep conditional comments, which some legacy email clients still act on.

What does removing attribute quotes do?

It drops the quotation marks around attribute values that do not need them. It is valid HTML and saves a few bytes, but it makes the markup harder to read and harder to edit by hand, so it is off by default.

Can I reverse a minify?

Use the HTML Formatter to indent it again. Comments that were removed cannot be recovered.

Is my markup uploaded?

No. Minification runs in your browser.

If the html minifier is not quite what you need, these other free tools solve closely related problems.

HTML Formatter

Pretty-print HTML with consistent indentation, or collapse it back down.

Code Formatters Use tool

CSS Minifier

Minify CSS by removing comments, whitespace and redundant characters.

Code Formatters Use tool

JavaScript Minifier

Shrink JavaScript by removing comments and whitespace, without renaming anything.

Code Formatters Use tool

Image Compressor

Compress and resize JPEG, PNG and WebP images privately in your browser.

Image Tools Use tool

Live HTML Editor

A three-pane editor with a live preview that updates as you type.

Developer Tools Use tool