Skip to content
GigAI Tools

HTML Minifier, Compress & Shrink HTML Online

Paste your markup and get the smallest safe HTML instantly, collapsed whitespace, stripped comments, and a live byte-saving readout. It never touches your <pre>, <textarea>, <script> or <style>, and nothing leaves your browser.

100% browser processingFree · no sign-up
Loading tool…

What is the html minifier?

The HTML Minifier shrinks page weight by collapsing whitespace and stripping comments, while safely preserving the contents of pre, textarea, script and style tags. A live readout shows exactly how many bytes you saved. It is free and runs entirely in the browser, so your markup never leaves the tab.

The GigAI HTML Minifier is a desktop-grade tool that compresses HTML entirely on your device. Drop in a page, a fragment or an email template and it collapses the runs of whitespace between and inside tags, removes comments, and trims the document to the smallest byte-safe form: showing you the input size, output size and exact percentage saved as you type. What makes it safe where a naive find-and-replace is dangerous: it lifts out every <pre>, <textarea>, <script> and <style> block and restores them verbatim, so significant whitespace, inline code and JavaScript templates survive untouched. It also keeps Internet-Explorer conditional comments (`<!--[if IE]>`) intact while stripping ordinary ones, so build-time markers still work. Because minifying runs locally with no dependency call to any server, you can safely shrink markup that contains customer data, API keys in data-attributes, unreleased copy or internal template variables. None of it is uploaded, logged or seen by anyone. Toggle comment stripping on or off, import a.html file by drag-and-drop, copy or download the result, undo and redo, and share a link that reopens the tool with your markup pre-loaded.

Difficulty:
Easy
Typical time:
~15s
Processing:
100% browser processing

Last updated

How to use the html minifier

  1. 1

    Paste, drop or import HTML

    Paste markup into the left editor, drag an .html file onto it, or click to browse. Or load the built-in sample to see it work instantly.

  2. 2

    Choose your options

    Keep comment stripping on for the smallest output, or turn it off to retain comments. Minification re-runs live as you change the toggle.

  3. 3

    Check the savings

    Watch the input, output and percentage-saved badges to confirm the minify is worthwhile before you use the result.

  4. 4

    Copy, download or share

    Copy the minified HTML, download it as an .html file, or share a link that reopens the tool with your markup pre-loaded.

What HTML Minifier includes

  • Preserves code & pre blocks

    Every <pre>, <textarea>, <script> and <style> is lifted out and restored byte-for-byte, so significant whitespace, inline JavaScript and code samples are never mangled.

  • Smart comment stripping

    Removes ordinary HTML comments to save weight, while keeping IE conditional comments (`<!--[if IE]>`) intact. Toggle stripping off when you need to keep build markers.

  • Live byte savings

    See input size, output size and the exact percentage saved as you type, so you know precisely what the minify bought before you ship it.

  • Instant as you type

    Minification re-runs on every keystroke with a smart debounce. No 'Minify' button dance, the output and stats stay in sync automatically.

  • Drop, paste or import

    Drag an .html file onto the editor, paste from the clipboard, or click to browse. Copy, download or share a link to the minified result in one click.

  • 100% in your browser

    All processing happens locally on your device. Markup containing customer data, keys in data-attributes or unreleased copy is never uploaded, stored or logged.

Why use our html minifier

Shave real weight off pages

Collapsing inter-tag and in-text whitespace and dropping comments trims the HTML the browser downloads, cutting transfer size on landing pages, SSR output and cached fragments.

Minify without breaking layout

Because whitespace-significant elements are preserved verbatim, you get the size win without the classic bug of a collapsed <pre> or a broken inline script template.

Clean up templated markup

Server-side templates leave gaps of indentation and comment scaffolding: one paste produces tight, production-ready HTML you can drop straight into a response or email.

Private by design

Everything runs on your machine, so you can safely minify internal templates, draft marketing copy or markup carrying embedded data with nothing leaving the browser.

Built for the way you work

From quick one-off fixes to daily workflows, see how people put this tool to use.

  • Frontend developer

    Trim server-rendered pages

    Paste SSR or templated output riddled with indentation and comment scaffolding, and get tight production HTML that shrinks the payload without altering the rendered result.

  • Email developer

    Shrink HTML email templates

    Collapse the whitespace in a bloated email template to fit under Gmail's clipping threshold, while keeping inline <style> blocks and conditional comments intact.

  • Performance engineer

    Measure a minify win

    Drop a page's HTML in to see the exact byte and percentage saving, quantifying whether adding HTML minification to the build is worth wiring up.

  • Content / marketing

    Clean embed snippets

    Tidy a copy-pasted widget or landing-page fragment into a compact one-liner that's easy to paste into a CMS field or documentation.

Supported formats

Accepts HTML, HTM and TXT, and produces HTML, all processed locally in your browser.

Input formats
  • HTML
  • HTM
  • TXT
Output formats
  • HTML

Frequently asked questions

Common problems, solved

Hit a snag? Here are quick fixes for the issues people run into most.

  • My inline <script> or <pre> spacing changed.

    It shouldn't. Those elements are preserved verbatim. If content still shifts, check that the tag is properly closed. An unclosed <pre> or <script> means the preserver can't find its end and the rest of the document is treated as normal text.

  • A comment I needed was removed.

    Turn off 'Strip comments' to keep all comments. Note that IE conditional comments (`<!--[if IE]>…<![endif]-->`) are always preserved even with stripping on, because they carry logic rather than notes.

  • The savings look small.

    Already-tight HTML has little whitespace to collapse. The biggest wins come from deeply indented, comment-heavy templated output. Hand-minified markup will barely move.

  • Nothing happens on a very large paste.

    Extremely large inputs are guarded to keep the tab responsive. Minify the document in sections, or trim it first. The limit is generous but not unbounded.

Get the most out of it

  • Keep 'Strip comments' on for the smallest output. Turn it off only when a comment carries a build-time marker you rely on.

  • IE conditional comments survive stripping automatically, so you don't have to choose between size and legacy support.

  • Press Ctrl/Cmd+Enter to re-run instantly and Ctrl/Cmd+S to download the minified HTML.

  • Check the 'Saved' badge before shipping, on already-tight markup the win may be too small to bother.

  • Minifying is safe on markup with embedded data or draft copy because everything stays in your browser.

What's new

Recent updates and improvements to the html minifier.

  1. Initial release, live whitespace collapse and comment stripping with pre/textarea/script/style preservation, IE conditional-comment safety, byte-saving stats, drag-drop import, undo/redo and shareable links.

  2. Added a comment-stripping toggle and keyboard shortcuts (run, download, clear, undo/redo) with an in-tool shortcuts helper.

Your privacy is built in

Your HTML is minified entirely in your browser. It is never uploaded to any server. Nothing is stored, logged or transmitted, so you can safely compress markup containing customer data, keys in data-attributes, or unreleased copy. Close the tab and every trace is gone.

  • Runs in your browser
  • No uploads
  • Nothing stored

Ready to try the html minifier?

Free, private and instant. HTML Minifier runs right in your browser.