Skip to content

HTML Minifier

Minify HTML safely: remove comments and extra whitespace while keeping scripts, styles and <pre> intact.

AvailableRuns in your browserFree · No sign-up

HTML Minifier

Options

Comments starting with <!--! are always kept.

<!--[if IE]> … <![endif]--> blocks for old Internet Explorer.

Runs of spaces and line breaks in text become one space. Never applied inside <pre>, <textarea>, <script> or <style>.

Like most minifiers. If you style <div>s as inline-block, this can remove the small gap between them.

Drops type="text/javascript" on <script> and type="text/css" on <style> and <link> (the defaults).

0 B

Paste code, choose a file or drop one here (up to 3.00 MB). Everything runs in your browser — the code isn't uploaded or run.

Your data is processed locally in your browser and is not uploaded to OZVILO servers.

How to use the HTML Minifier

  1. 1Paste HTML, choose an .html or .htm file, or drop one onto the box.
  2. 2Pick options: comments, conditional comments, whitespace and redundant type attributes.
  3. 3Press Minify HTML and check the original size, minified size and percentage saved.
  4. 4Copy the result or download it as .html.

Examples

  • Indented page

    Input
    <p> Hello <b>world</b> </p>
    Result
    <p>Hello <b>world</b></p>
  • Inline script

    Input
    <script> console.log("a b"); </script>
    Result
    Kept exactly as written

HTML Minifier features

  • Removes comments (keeps conditional comments and <!--! notices if you like)
  • Collapses whitespace in text, keeping the spaces that separate words and inline elements
  • Never changes <script>, <style>, JSON-LD, <pre>, <textarea> or attribute values
  • Built-in safety check: the result must parse to the same elements, attributes and text
  • Original and minified size, bytes saved and percentage; runs in your browser

Frequently asked questions

Can minifying break my page?

The tool only removes comments and whitespace that doesn't render, and checks that the result has the same elements, attributes and text before showing it. One thing to know: removing whitespace around block elements can close the small gap between elements you've styled as inline-block — turn that option off if you rely on it.

Does it minify the CSS and JavaScript inside my HTML?

No. Inline <script> and <style> blocks are kept exactly as written, which avoids breaking them. Use the CSS Minifier and JavaScript Minifier for separate files.

Is my HTML uploaded?

No. Minification runs in your browser, and the HTML is never executed.

How much will my pages shrink?

It depends on how much indentation and how many comments the HTML has; the tool shows the exact saving for your file. Servers that use gzip or Brotli compression already shrink repeated whitespace a lot, so the saving in transfer size is usually smaller.