Minify HTML
Strip comments and whitespace, and shrink the CSS and JavaScript inside the page — without disturbing the spacing that actually renders. Your source never leaves the browser.
- Processed on your device
- No upload, no waiting
- No signup, no watermark
The minified HTML appears here.
How it works
Paste your HTML
Or drop the file in. Nothing is uploaded — this matters more for source than for most things.
Choose how far to go
Comments, whitespace, inline CSS and inline JavaScript are each separate switches.
Copy or download
You are shown how much smaller it got, before and after.
Frequently asked questions
Is my code uploaded?
No, and for source code that is the point. Nothing is uploaded and no request leaves your device. Pasting proprietary source into an online minifier that posts it to a server is a disclosure, whatever the site says about retention — and it is exactly the sort of thing that is done in a hurry without thinking.
Will minifying break how the page looks?
Not the way it is set up here. Whitespace is only collapsed where it does not render: between block elements such as divs and list items. The space BETWEEN INLINE elements is kept, because removing it visibly joins two words together — "</span> <span>" is a real space on screen and "</span><span>" is not. The contents of <pre> and <textarea> are left byte for byte alone. And removing optional closing tags is deliberately switched off: it is valid HTML, but a good many template engines and email clients parse the result badly.
What does it actually remove?
Comments, whitespace that never rendered, and the slack inside <style> and <script> blocks. Your markup structure, attributes and text are untouched — the tool is checked by parsing the page before and after and confirming the element count, the list items and the visible text are identical.
Should I remove attribute quotes?
Only if the output is going straight to a browser. It is valid HTML and it saves a little, but unquoted attributes break some template engines, some email clients and most naive parsers. It is off by default and the page warns you when you switch it on.
Does it minify the CSS and JavaScript inside the page?
Yes, both, using the same engines as our CSS and JavaScript minifiers. One exception: if your inline CSS uses native nesting or modern media queries, the CSS pass is switched off for that run — the CSS minifier predates those features and would silently delete rules. The HTML is still minified, and the page tells you that happened rather than handing back a page missing styles.
How much smaller will it get?
For hand-written HTML with indentation and comments, commonly 10–30%. Then gzip on your server does most of the remaining work — minifying first still helps, because the two compound, but do not expect minification alone to halve a file.
Which library is it?
html-minifier-terser 7.2.0, which is MIT-licensed, served from this site rather than a CDN, and downloaded only when you open this page.
More Text Utilities tools
CSS Minifier
Shrink a stylesheet, or be told why not
JavaScript Minifier
Compress JavaScript with terser, privately
XML Formatter
Indent XML so you can read it
Markdown Preview
See your Markdown the way GitHub renders it
Duplicate Line Remover
Remove repeats, sort and tidy a list
Case Converter
UPPER, lower, Title Case, camelCase and the rest