⚡
usefultools.dev
</>

HTML Minifier

NOUVEAU

Minify HTML in your browser: remove comments and extra whitespace, keep pre, textarea and script content intact, and see the bytes saved.

Fonctionne à 100 % dans votre navigateur — vos données ne sont jamais envoyées ni stockées sur nos serveurs.

Cet outil n'est pas encore entièrement traduit : une partie du texte est encore en anglais. L'outil lui-même fonctionne de la même façon dans toutes les langues.

Options

What is kept exactly: the content of <pre>, <textarea>, <script> and <title>, attribute quotes and values (only whitespace around a few attributes such as class is trimmed), and the single space between inline elements such as links and spans.

Whitespace modes: safe mode removes spaces next to block elements such as div, p and li. If your CSS turns those into inline-blocks, use conservative mode. Aggressive mode also removes the space between inline elements and text, which can join words. The HTML is parsed as text, never executed.

⚡

Exemples rapides

Des entrées typiques et les résultats produits par cet outil.

Whitespace
<p> Hello <b>world</b> </p>
<p>Hello <b>world</b></p>
Inline gap
<a href="/a">One</a> <a href="/b">Two</a>
<a href="/a">One</a> <a href="/b">Two</a>
Comment
<!-- note --> <div class=" a b ">x</div>
<div class="a b">x</div>
Keeps pre
<pre> a b </pre> <p> x </p>
<pre> a b </pre><p>x</p>
📖

Présentation

The HTML minifier shrinks a page by removing what browsers do not need: comments, indentation, line breaks and repeated spaces. Smaller HTML means fewer bytes to download, which helps page speed.

It reads the markup with a tokenizer rather than a pattern replace, so the content of pre, textarea, script and title stays exactly as written and attribute quotes are never removed. A single space between inline elements such as links and spans is kept, so buttons and menus do not collapse into each other.

Options let you keep conditional and Knockout comments, minify inline CSS, trim class attributes and choose safe, conservative or aggressive whitespace. The result shows the size before and after, and everything runs in your browser.

Pourquoi utiliser cet outil ?

  • Cut page size before deploying static HTML
  • Inline spaces and pre content stay intact
  • See bytes and percent saved immediately
  • Nothing is uploaded, code stays in your browser
  • Free, no sign-up
⭐

Fonctionnalités

🧹

Whitespace collapse

Removes indentation and line breaks and keeps one space where text needs it.

💬

Comment control

Removes comments but can keep IE conditional comments and Knockout <!-- ko --> comments.

🛡️

Protected content

The content of pre, textarea, script and title is copied exactly as written.

🎨

Inline CSS

Minifies style elements and style attributes by removing comments and extra spaces.

⚙️

Three whitespace modes

Safe, conservative (keep one space) or aggressive (drop it between all tags).

📊

Size report

Shows original and minified bytes, bytes saved and the percentage, then copy or download the file.

🛠️

Mode d'emploi

1

Add your HTML

Paste the markup, use Upload file, or press Load sample.

2

Choose a whitespace mode

Keep Safe for most pages, or use Conservative if your CSS changes how block elements display.

3

Check the options

Decide which comments to keep, whether to minify inline CSS and whether to trim attribute whitespace.

4

Copy or download

Read the size report, then press Copy or Download .html.

🤔

Questions fréquentes