HTML Minifier

Compress HTML by stripping comments & whitespace.

Minify HTML online: remove comments and collapse the whitespace browsers ignore, while preserving <pre>/<textarea> exactly and optionally minifying inline CSS and JavaScript. See the byte and gzip savings instantly. Runs fully in your browser — nothing is uploaded.

How to use HTML Minifier

  1. Paste your HTML

    Paste your markup or upload an .html file into this free online HTML minifier to compress it instantly in your browser, with nothing uploaded.

  2. Collapse whitespace

    Keep Collapse whitespace on to squeeze out the indentation and blank lines browsers ignore, shrinking the HTML while it renders identically.

  3. Remove comments

    Enable Remove comments to strip developer notes from the markup, while conditional and important comments are safely preserved.

  4. Minify inline CSS and JS

    Turn on Minify inline CSS and JS to compress the style and script blocks too, and use Remove space between tags for the most aggressive HTML minification.

  5. See the savings

    The minified HTML appears instantly with a stats strip showing the byte savings and the gzipped size that really travels over the network.

  6. Copy or download

    Copy the minified HTML to your clipboard with one click or download it as a ready-to-deploy .html file straight from your browser.

Frequently asked questions

Will minifying break my page?

No. It only removes whitespace and comments the browser already ignores, and it preserves the exact content of <pre>, <textarea>, <script> and <style>. The rendered result is identical — just smaller. The one option to use with care is “Remove space between tags”, which can change spacing between inline elements (like adjacent <span>s).

How much smaller will my HTML get?

Typically 10–30% on hand-written, indented HTML, and more once inline CSS/JS minification is included. The exact saving — including the gzipped size, which is what really travels over the network — is shown in the stats strip above.

What is the difference between minified and gzipped size?

Minifying removes redundant characters from the source. Gzip then compresses what is left when the server sends it. Both stack: a minified file also gzips a little smaller. We show both so you can see the real over-the-wire size.

Should I minify by hand or in my build?

For production sites, wire minification into your build pipeline (Vite, webpack, a CDN) so every deploy is optimised automatically. This tool is perfect for one-off files, quick checks, emails, landing pages, and learning exactly what minification does.

How do I minify HTML online for free?

Paste your markup (or load the sample) into this free online HTML minifier and the compressed output appears instantly, ready to copy or download as a .html file. Toggle options like collapse whitespace, remove comments and minify inline CSS/JS to control how aggressively your HTML is minified.

Why should I minify HTML for my website?

Minifying HTML reduces file size and removes the comments and whitespace browsers ignore, so pages download faster and score better on Core Web Vitals and SEO. Smaller HTML means quicker first paint, less bandwidth and a snappier site without changing how the page renders.

Is anything sent to a server?

No. All processing happens locally in your browser with JavaScript — nothing is uploaded, logged or stored.

Can I minify HTML with inline CSS and JavaScript?

Yes. Turn on the inline CSS/JS options and the minifier also compresses the styles inside <style> tags and the scripts inside <script> tags, squeezing extra bytes out of a single-file page without changing how it renders.

Will minified HTML still work if I edit it later?

It runs identically, but minified HTML is hard to read and edit by hand because the indentation and comments are gone. Keep your original, readable source for editing and use the minified copy only for production — or re-format it later with an HTML beautifier if you need to work on it.

Related tools — Minifiers