HTML Minifier

Paste a page or a snippet and get a compact version. Comments and surplus spaces go, while text, preformatted blocks and scripts are left as written.

Este conteúdo está em inglês.

Exemplos resolvidos

A small card

<div class="card"> <!-- title --> <h2> Hello <b>big</b> <i>world</i> </h2> <p> One line. </p> </div>

<div class="card"><h2>Hello <b>big</b> <i>world</i></h2><p>One line.</p></div> Original size: 118 bytes Minified size: 78 bytes Saved: 40 bytes (34%) Comments removed: 1

The comment and extra spaces go. The space between the bold and italic words stays.

Styles and preformatted text

<style> a { color : red ; } /* note */ .box > p { margin : 0 auto ; } </style> <pre> keep this </pre>

<style>a{color:red}.box>p{margin:0 auto}</style><pre> keep this </pre> Original size: 113 bytes Minified size: 74 bytes Saved: 39 bytes (35%) Comments removed: 0

The style rules are shortened and the comment removed, while the pre block is untouched.

Sobre HTML Minifier

This HTML minifier makes markup smaller by taking out what a visitor never sees. Comments are removed, runs of spaces and line breaks are collapsed, and the gaps between block level tags such as div, p and li are dropped. Smaller HTML downloads faster, which helps page speed.

It is careful about the places where spaces matter. A space between inline elements such as links, bold text and spans is kept so words do not join up, and the contents of pre, textarea and script tags are left exactly as written. Styles inside style tags can be shortened too. The result shows the size before and after.

Como usar HTML Minifier

  1. Paste your HTML, or open an HTML file.
  2. Choose whether to remove comments, collapse whitespace, shorten styles and remove quotes around simple attribute values.
  3. Check the bytes saved, then copy the result or download it.

Usos comuns

  • Shrinking a landing page or an email template before it goes live
  • Reducing the size of HTML stored in a database or sent through an API
  • Checking how much of a page is formatting rather than content
  • Preparing a snippet to paste into a field that has a length limit

Perguntas frequentes

Is the minified page identical to the original?

It should look the same. Collapsing whitespace can change the layout of unusual markup, for example when inline blocks rely on the space between them, so always test the result.

Are scripts minified?

No. Scripts are left as written, because shortening code safely needs a full parser. Use the JavaScript minifier for script files.

What happens to conditional comments?

Comments that start a conditional block for old versions of a web browser are kept, because removing them changes what the page does.

Should I remove attribute quotes?

It saves a few bytes and is valid HTML when the value has no spaces or special characters. Leave it off if you want the most conservative result.