HTML Minifier
Shrink HTML by removing comments and collapsing whitespace, while leaving preformatted text, inline scripts, and inline styles untouched. See the size saved.
Minified live as you type. Markup never leaves your browser.
Options
Comments
Whitespace inside pre, textarea, script, and style is always preserved, and character references are never decoded.
How to minify HTML online
Paste your HTML
Drop a page or a fragment into the input and the minified markup appears immediately below.
Choose what to strip
Toggle collapsing whitespace, removing comments, and stripping optional quotes and attributes, and keep conditional comments if you need them.
Copy the result
Check the percentage saved, then use Copy HTML to grab the minified markup and paste it wherever you need it.
Why use this tool
Collapse whitespace safely
Runs of spaces, tabs, and line breaks between tags collapse to a single space, which strips indentation without removing the gaps that matter between inline elements.
Remove comments
Deletes comments from the markup, with an option to keep conditional comments so pages that target older browsers still behave.
Preserves the sensitive parts
Text inside pre and textarea stays exactly as written, and inline scripts and styles pass through untouched, so preformatted content and code keep working.
Optional quotes and attributes
Turn on the extra pass to drop redundant attribute quotes and remove default type declarations on scripts and stylesheets for a smaller result.
Size saved readout
Shows the size before and after minifying plus the percentage saved, so you can see exactly what the smaller markup is worth.
Runs entirely in your browser
Everything happens on your device. Your markup, scripts, and styles are never uploaded.
About this tool
This HTML minifier strips the parts of a page that only exist for humans: comments, indentation, line breaks, and the runs of whitespace between tags. It reports the size before and after with the percentage saved, so shrinking a template is paste, glance at the savings, copy. The output is your markup with the padding removed, not a rewritten page, which makes it safe to drop straight into a build.
The collapsing is deliberately careful. Whitespace inside a pre, textarea, script, or style block is left exactly as written, so preformatted text, inline scripts, and inline styles keep working. Runs of whitespace in ordinary text collapse to a single space rather than vanishing, which preserves the meaningful gap between inline elements like links and spans. Character references such as named and numeric entities are never decoded, so they survive untouched.
Use the toggles to control exactly what changes: keep conditional comments if your page relies on them for older browsers, turn off whitespace collapsing to only strip comments, or enable optional quotes and attributes to remove redundant markup for a smaller file. Everything runs in your browser, so client sites and unreleased pages never leave your device. For readable output instead, the HTML formatter re-indents the same markup, and the CSS minifier shrinks stylesheets the same way.
Frequently asked questions
- What does minifying HTML actually remove?
- By default it removes comments and collapses runs of whitespace between tags to a single space, which strips the indentation and line breaks that make up most of a hand-written page. It never rewrites your tags or content, so the result renders the same, just smaller.
- Will minifying break my page, scripts, or styles?
- No. Whitespace inside pre and textarea is preserved exactly, and inline scripts and styles are passed through untouched, so code and preformatted text keep working. Whitespace between inline elements collapses to a single space rather than being deleted, so spacing between links and spans is kept.
- Can I keep conditional comments for older browsers?
- Yes. When removing comments is on, the keep conditional comments toggle preserves comments that open an [if ...] block or close one with [endif], so pages that rely on them for older browsers still work while every other comment is stripped.
- What do the optional quotes and attributes do?
- That optional pass drops the quotes around attribute values that do not need them and removes default type declarations on scripts and stylesheets. It is off by default because it changes how tags are written, even though the page renders identically.
- Is my HTML uploaded anywhere?
- No. Everything runs in your browser and the markup never leaves your device, which matters when the page belongs to a client project or an unreleased product.
- Is there a limit on file size?
- No fixed limit. Processing happens in your browser tab, so large files are bounded by your device memory rather than an upload cap, and the output area scrolls instead of stretching the page.
Related tools
HTML Formatter & Beautifier
Beautify messy or minified HTML with indent, line wrap, and line break control.
CSS Minifier
Strip comments and whitespace from CSS to shrink it, or beautify a minified stylesheet back into readable rules, with a size saved readout.
JSON Minifier
Minify JSON to the smallest single line, with original vs minified byte size and the percentage saved.
API Key Generator
Generate cryptographically random API keys and tokens in hex, base62, or base64url, with control over length, an optional prefix, and bulk output.
ASCII Table Reference
The full ASCII character set with decimal, hex, octal, binary, and HTML codes. Search by code, character, or name.
Atbash Cipher
Mirror the alphabet so A swaps with Z, B with Y, and so on. Atbash is its own inverse, so one field both encodes and decodes as you type.