HTML Minifier

Minify HTML.

Loading tool…

What is HTML minification?

HTML is the structure of a web page: elements, attributes, and the text between them. Source HTML carries a lot the browser does not need — indentation, line breaks between tags, developer comments, and sometimes redundant attribute quoting.

Minification strips those. It also collapses runs of whitespace between elements, removes optional closing tags where the specification permits, and can inline-minify embedded style and script blocks. The one genuine hazard is whitespace inside content: in HTML, the space between two inline elements is meaningful and rendered, so an over-aggressive minifier can visibly close a gap between words or links. A good minifier collapses whitespace without deleting it entirely, which is why you should always eyeball the result.

Why we built this tool

Markup minification pays off most where pages are large and repetitive — generated tables, catalogue listings, email templates, and static sites with hundreds of pages — and on HTML email, where several clients still impose hard size limits and clip anything longer.

Templates and unreleased pages are client work, and there is no reason to hand them to a third-party server for whitespace removal. Ours parses and rewrites the markup in your browser, so the page source stays on your device, has no size limit, and needs no account. It is also fast enough to sit in your workflow as a final step before you paste the output into a production template.

Tips and common mistakes

  • Check spacing between inline elements after minifying — this is the one place aggressive whitespace removal is visible.
  • Preserve content inside <pre> and <textarea>, where whitespace is meaningful.
  • Conditional comments still matter for older Outlook rendering in HTML email; do not strip them there.
  • Keep HTML email under roughly 102 KB so Gmail does not clip the end of your message.

Open HTML Minifier with a link

HTML Minifier can be handed its input by the link that opens it, so the page arrives with the work already done. This is meant for assistants and scripts: if a chatbot, an editor extension, or a command-line agent already holds your content, it can build a link instead of asking you to copy and paste into a box.

The payload rides in the fragment — the part of a URL after the #. Browsers never send the fragment to a server, so anything handed over this way stays on your device exactly as a dropped file would. A link that uses the query string instead is rewritten into the fragment by the page before any analytics or ad script can read the address.

Prefix any field with gz#gztext= — to pass it as gzip-compressed base64url, which fits roughly five to ten times more into the same link. Links stay reliable up to about 8,000 characters; past that, chat apps and address bars start truncating them, and the page says so rather than loading half a document.

One exception to the privacy rule: ?url= tells the page to download the input from an address. That request goes from your browser straight to that server — not through ours — but it does leave your device, and it only works if the server allows cross-origin requests.

  • #text= — the text to work on
  • #html= — the HTML

Example: https://mygadgets.ink/tools/html-minifier/#text=...&html=...

Quick start: using HTML Minifier

  1. Paste your HTML or load the file above.
  2. Run the minifier and note the byte reduction.
  3. Render the output and compare it against the original page carefully.
  4. Look specifically at spacing between inline links, buttons, and words.
  5. Copy the minified markup into production, keeping your source version intact.

Minify the assets too: CSS Minifier and JS Minifier.

Related Developer Tools

Browse all Developer Tools →