Skip to content

Minify HTML

Remove whitespace, comments and redundant attributes from HTML, and minify inline CSS and JavaScript at the same time.

  • Runs in your browser
  • Code never uploaded
  • Free

Your HTML

Minified

What HTML minification does

HTML minification collapses whitespace between tags, removes comments and optional quotes, and shortens boolean attributes like disabled="disabled" to disabled. It can also minify the CSS and JavaScript inside style and script tags.

It's most useful for static sites, email templates and pages that are served without a build step.

How to minify HTML

  1. 01

    Paste or drop your code

    Paste HTML into the left box, or drop a file onto the page.

  2. 02

    It's minified instantly

    html-minifier-terser minifies it as you type. Adjust the options above the editor if you need to.

  3. 03

    Copy or download

    Copy the result, or download it as a .min file. The size savings, including gzipped size, appear below.

Features

Four languages

JavaScript with Terser, CSS with CSSO, HTML with html-minifier-terser, and JSON.

Real savings

See original, minified and gzipped sizes, which is what visitors actually download.

Instant

Minification runs in a background thread as you type, so even large files stay responsive.

Clear errors

Syntax errors show the line and column so you can fix the source quickly.

Your code stays private

Nothing is uploaded. Minify proprietary code without sending it to anyone.

Free and open source

No limits, no sign-up, and the source is on GitHub.

Frequently asked questions

Is my code uploaded?

No. Minification runs entirely in your browser in a Web Worker. Your code never leaves your device.

Is it safe to minify HTML?

Yes for nearly all pages. Whitespace inside pre and textarea is kept. If inline elements look squashed together, check for spaces you relied on between tags.

Does it minify inline CSS and JavaScript?

Yes, when Minify inline CSS and JS is on. Style blocks and attributes use clean-css, and scripts use Terser.

Is minification the same as obfuscation?

No. Minifying makes code smaller and is easy to reverse with a formatter. To make JavaScript hard to read, use the JavaScript Obfuscator at obfuscate.devsamc.xyz.

More free tools