Updated 2026 · By ToolFern

HTML Minifier

Compress HTML online by stripping comments and collapsing the extra whitespace between tags. Smaller files download faster, and everything runs 100% in your browser, so nothing is uploaded.

How to use it

  1. Paste your HTML into the input box, or start typing.
  2. The output updates live as you type, or press Minify to run it on demand.
  3. Check the stats line to see the original size, the minified size and how much you saved.
  4. Press Copy to grab the minified HTML for your page or build.

How HTML minification works

Source HTML is usually written for humans. It is indented, spread across many lines, and sprinkled with comments that explain the markup. Browsers do not need any of that. Minification removes the parts that do not affect rendering so the file gets smaller without changing how the page looks.

This tool does two main things. First it removes HTML comments, the <!-- ... --> blocks that never reach the screen. Second it collapses runs of whitespace between tags, including newlines and indentation, down to a single space, then trims the result. Smaller HTML means fewer bytes over the wire, which is a real win on large pages and slow connections.

Because whitespace is collapsed to a single space rather than deleted outright, the normal spacing between inline elements stays intact, so your layout does not shift. If you depend on exact whitespace inside pre ortextarea blocks, give the output a quick check before you ship it.

Frequently asked questions

Is my HTML sent anywhere?

No, it is minified in your browser and never uploaded.

How much smaller will it get?

Often 10 to 30 percent for hand-written HTML. The stats line shows your exact saving.

Does it minify inline CSS and JavaScript?

No, it focuses on HTML structure. Use a dedicated CSS or JS minifier for those.

Related: JSON Formatter