HTML Minifier
Strip whitespace and comments from HTML. Useful for embed code, email templates, or production HTML.
How to use this tool
- 1
Paste your HTML — a fragment, a component, or a small template.
- 2
The minified result and the new byte count appear instantly below.
- 3
Copy the minified HTML for your embed, email, or snippet.
What HTML minification does — and where to use it carefully
HTML minification removes characters a browser doesn't need to build the page: comments and the whitespace between tags. The parsed result — the DOM the browser actually constructs from ordinary markup — is identical; only the byte count drops. For a typical hand-written page the raw saving is modest (often 10–20%) because HTML already compresses well with gzip and Brotli, but minification still helps where markup ships on every single load: a server-rendered fragment returned by an API on each request, an email template duplicated across thousands of sends, or an embed snippet pasted onto other people's sites. This tool is a lightweight minifier: it strips HTML comments and collapses runs of whitespace, which is perfect for simple, self-contained snippets. It is intentionally not whitespace-aware, so it should be used carefully on documents that contain whitespace-sensitive regions — anything inside <pre>, <code>, or <textarea>, content styled with 'white-space: pre', or inline <script> where line breaks matter — because collapsing the spacing there can change what renders or how code behaves. For minifying whole production pages, let a build-time tool like html-minifier-terser handle it; it understands those special elements and preserves them. Reach for this on-demand minifier when there's no build step in the loop and your snippet is plain markup.
Common use cases
Compress a simple HTML email template, where size affects deliverability and there's no build pipeline.
Minify a plain embed or widget snippet that gets pasted onto many external pages.
Trim server-rendered HTML fragments returned by an API or AJAX endpoint on every request.
Remove developer comments from markup before it's exposed in a public 'View Source'.
Shrink a small static HTML file you're hosting directly without a bundler.
Quickly see how much weight comments and whitespace add to a chunk of markup.
Frequently asked questions
Will minification break my layout?▼
Does it minify inline CSS and JavaScript?▼
Is minification worth it if I already gzip?▼
Should I commit minified HTML to my source?▼
What exactly does this tool remove?▼
Is my HTML uploaded?▼
Related tools
JWT Decoder
Decode JSON Web Tokens (JWT) instantly — inspect the header, payload, and signature claims. Runs entirely in your browser; tokens never leave your device. Safe for production secrets.
JSON Formatter & Validator
Format, validate, and minify JSON instantly. Catches syntax errors with line numbers, pretty-prints with adjustable indent, supports large payloads. Runs in your browser — no upload.
XML Formatter & Beautifier
Format and beautify XML documents — proper indentation, line breaks, namespace handling. Useful for SOAP responses, sitemaps, RSS feeds, and Android resource files.
Base64 Encoder & Decoder
Encode and decode Base64 strings.
URL Encoder & Decoder
Encode/decode URL-safe strings.
HTML Entity Encoder & Decoder
Convert special characters to/from HTML entities.