Minify HTML — strip comments, whitespace, optional attributes, inline CSS/JS. 40-60% smaller.
- Runs locally
- Category Format Converter
- Best for Turning pasted content or local files into a handoff-friendly format.
Minified output appears here.What this tool does
Free online HTML minifier and compressor. Paste a raw HTML document (full page, fragment, email template, AMP page, server-rendered output) and get a production-tight single-line version typically 40-60% smaller than the input. Every transform is an opt-out checkbox: strip comments (but keep conditional <!--[if IE]--> and SSI <!--#include-->), collapse all whitespace between tags, collapse runs of whitespace inside text nodes to a single space, remove redundant attribute quotes when the value contains no spaces / quotes / equals / angle-brackets (id="x" → id=x, safe per HTML5 spec), normalize boolean attributes (disabled="disabled" → disabled, same for checked / selected / readonly / required / autofocus / hidden), and drop optional closing tags (</li> </tr> </td> </th> </p> when the next sibling makes the close inferable per the HTML5 parser rules). The tokenizer is HTML5-aware: it respects raw-text elements (script, style, textarea, pre — text inside is never collapsed), CDATA, entity references, and self-closing void elements (img, br, hr, input, meta, link). Live size diff (original / minified / saved %) under the output. 100% client-side — your unreleased landing pages, email blasts, and internal templates never leave the tab. Pair with our CSS Minifier and JS Minifier for a complete pre-deploy squeeze; pair with HTML Entities Encoder when you need to inline HTML in a JSON or XML payload.
Tool details
- Input
- Text + Structured content
- The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
- Output
- Live result + Copy + Download
- The result area focuses on usable output, with copy, download, or preview actions when supported.
- Privacy
- Browser-side processing
- The main tool logic does not call an external API, so inputs normally stay in the current tab.
- Save / share
- No account required
- Open the page and use it; whether results survive refresh depends on the tool.
- Performance budget
- Initial JS <= 14 KB
- No WASM budget is declared, keeping the tool quick to open on mobile.
- Best fit
- Format Converter · Developer
- Category and role tags drive related tools, internal links, and quick fit checks.
How to use
-
1. Input
Paste or drop your content into the tool panel.
-
2. Process
Click the button. All processing is local in your browser.
-
3. Copy / Download
Copy the result or download to disk in one click.
How HTML Minifier fits into your work
Use it when the main problem is getting content from one practical format into another.
Conversion jobs
- Turning pasted content or local files into a handoff-friendly format.
- Previewing a conversion before you use it in a larger workflow.
- Cleaning small format mismatches without opening a full editor.
Conversion checks
- Try a small sample first when the source format is messy.
- Check character encoding, separators, and line endings after conversion.
- Keep the source until the converted output has been reviewed.
Good next steps
These links move the current task into a more complete workflow.
- 1 JS Minifier Minify JavaScript — strip comments, whitespace, optional name shortening. 40-70% smaller. Open
- 2 CSS Minifier Minify CSS — strip comments, whitespace, shorten colors, merge selectors. 30-60% smaller. Open
- 3 CSS Formatter & Minifier Format and beautify CSS — sort properties, indent rules, expand or minify. Open
Real-world use cases
Squeeze a transactional email template before it hits the ESP
Outlook-targeted email HTML is bloated: nested tables, repeated inline styles, IE conditional comments. Paste the 90 KB template, keep "preserve conditional/SSI comments" on, and you ship a 38 KB body. That clears Gmail's 102 KB clipping threshold, so your CTA and unsubscribe footer stay visible instead of getting hidden behind a "[Message clipped] View entire message" link.
Trim server-rendered fragments returned over HTMX or Turbo
When your backend returns HTML partials on every interaction, the whitespace your template engine emits is pure transfer cost. Run a 12 KB Jinja-rendered table fragment through here and it drops to around 7 KB. Across a list view that swaps 30 times a session, that is real bytes off the wire and faster swaps on slow mobile connections, with the DOM identical after parsing.
Compare your build pipeline output against a known-good baseline
You suspect your Vite html-minifier-terser config is leaving bytes on the table. Paste the same source here, diff the two outputs byte by byte, and you can see exactly which transform your config skipped: maybe collapseBooleanAttributes is off, or optional tags are still being closed. Now you know which flag to flip in vite.config.ts instead of guessing.
Shrink an AMP page to stay under the 75 KB document limit
AMP rejects pages whose document HTML exceeds 75 KB. A landing page with a long inline <style amp-custom> block and verbose markup can sit right at the edge. Minify the markup (the tool leaves raw-text style contents intact, so your amp-custom rules survive) and reclaim 8 to 12 KB, pushing the page back under the ceiling so the AMP validator passes.
Common pitfalls
Running CSS or JS through this tool expecting it to shrink. It only touches markup; <style> and <script> contents pass through untouched. Pipe those to the CSS Minifier and JS Minifier instead.
Turning off "preserve conditional/SSI comments" on an Outlook email, then losing your <!--[if mso]> fallbacks. Leave that toggle on for any email or legacy-IE template.
Pasting a fragment that opens inside a <pre> or <textarea> without its parent tag. The tokenizer can't see it's raw text, so it collapses whitespace you needed. Always include the wrapping element.
Privacy
This minifier runs entirely in your browser. The HTML you paste is tokenized and rewritten in JavaScript on the page; nothing is uploaded to a server, and the input is never placed in the URL or shared link. Unreleased landing pages, internal email blasts, and private templates stay in the tab. Close it and the text is gone.
FAQ
Tool combos
Folks in your role tend to reach for these alongside this tool.
- 555 Timer Calculator Astable f = 1.44/((R1+2R2)C) + monostable t = 1.1RC — pick R1, R2, C in Ω/kΩ and µF/nF, read frequency, duty cycle and pulse width — browser-only
- Add Line Numbers Number every line of pasted text — set start, step and separator, zero-pad to align, skip blanks, or strip numbers back off — browser-only
- AES Text Encryptor Encrypt & decrypt text with a password — AES-256-GCM + PBKDF2 via WebCrypto — 100% in your browser, nothing uploaded
- Affine Cipher Encoder & Decoder Encrypt and decrypt the ax+b affine cipher with live modular-inverse check, browser-only