Compress HTML by stripping whitespace, comments, and redundant markup - free, no signup required.
Input HTML
Minified Output
Original: 0 BMinified: 0 BSaved: 0.0%
HTML Full Form
HTML stands for HyperText Markup Language - the standard markup language used to structure content on the web.
HTML source is written for humans to read and edit, so it's full of indentation, line breaks, and comments - all discarded by the browser at render time. Minifying HTML strips these away to produce a smaller document that, with the one exception described below, renders the same.
What this tool does
Strip comments - Removes HTML comments (IE conditional comments are preserved).
Collapse whitespace - Removes indentation, newlines, and redundant spaces between tags.
Preserve sensitive blocks - pre and textarea contents are kept exactly as written, because whitespace inside them is visible on the page.
Inline CSS & JS minify - style blocks are CSS-minified and script blocks are JS-minified automatically. Scripts with a data type such as application/ld+json are left as they are.
Byte savings - See original vs minified byte counts and percentage saved.
When minifying HTML pays off
The gain is biggest on pages that are written by hand and served often: a landing page, an email template, a static site without a build step, or an HTML snippet that a CMS stores and repeats on every page. Email is a good case, because some clients clip long messages, so trimming the markup can keep the whole email visible.
How to use it
Paste your markup into Input HTML, or click Upload File to open an .html or .htm file. Load Sample fills in a short page that shows each rule in action.
The minified version appears on the right as you type. Click Minify to run it again on demand.
Read the stats line to see how many bytes you saved.
Use Copy or Download (saved as minified.html), or Clear to start over.
How the minifier works
Before touching anything, the tool sets aside every <pre>, <textarea>, <script> and <style> block so its rules cannot damage them. It then deletes ordinary comments, removes whitespace that sits only between a closing > and the next <, and squeezes any remaining run of spaces, tabs and newlines down to a single space. Finally it puts the protected blocks back, with the CSS and JavaScript inside them minified by the same engines as our CSS Minifier and JS Minifier.
Example, and the one thing to watch
This input:
<p>Hello <b>big</b> <i>world</i></p>
becomes:
<p>Hello <b>big</b><i>world</i></p>
The space after "Hello" survives because it touches text, but the space between the two inline tags is removed, so the page now reads "Hello bigworld". The same happens between links in a menu or between inline-block buttons. Where a gap matters, put the space inside a tag, use , or create the gap with CSS margin.
Other limits
Repeated spaces inside attribute values are also reduced to one, so title="a b" becomes title="a b".
Optional tags, quotes around attributes and boolean attributes are left as written. The tool removes whitespace and comments, it does not rewrite your markup.
Server template syntax such as PHP, Jinja or Liquid should be rendered first. Minify the final HTML, not the template.
Privacy
Everything runs locally in your browser. Your HTML is never sent to our servers, not even for analytics.
Frequently Asked Questions
Will minifying break my HTML?
For 99% of documents, no. The minifier preserves pre, textarea, script, and style contents verbatim, keeps IE conditional comments, and keeps CDATA sections. Whitespace between inline tags is collapsed, so if you rely on it for spacing, use an nbsp or CSS margin.
Does it minify inline CSS and JavaScript?
Yes. Style blocks are passed through the CSS minifier and script blocks through the JS minifier before being re-embedded. Script tags with non-JS types (like application/json) are left untouched.
How much can I realistically save?
Hand-authored HTML shrinks by 20-40%; build-tool-generated HTML by 5-15%. After gzip the saving is smaller but still real - minification removes tokens the compressor still has to encode.
Is my HTML uploaded anywhere?
No. All minification runs inside your browser using client-side JavaScript. Nothing is sent to our servers, nothing is logged, and nothing is cached anywhere except your own browser tab.
Can I reverse the minification?
Click Beautify to pretty-print any HTML with indentation. Original comments are not recoverable, but document structure is fully restored and readable again.
Should I minify before or after templating?
After. Minifying template source before variable interpolation can mangle template syntax (Jinja, Liquid). Do interpolation first, then minify the rendered output as part of your build step.
By continuing, you agree to our
Terms of Use and
Privacy Policy,
and confirm you are at least 13 years old.
You're offline
Check your connection. This page will reload on its own the moment you're back online.
Trying to reconnect...
Choose an imageUpload a new picture, or pick one you have used before.
Drag a picture hereAdd a photo from your phone
JPG, PNG, WebP or GIF. Big photos are made smaller for you. You can also paste a picture. You can crop it next.
Uploading
That did not upload.
Drop to upload
Your pictures
No picture matches that name.
Crop imageDrag to reposition · zoom to crop, or fit the whole image