HTML Minifier
Minify HTML by removing comments and collapsing whitespace, with inline CSS minification and a live size-saved readout.
- Original size
- 0 B
- Minified size
- 0 B
- Saved
- 0%
- Status
- Waiting
How it works
Paste HTML on the left and the minified markup appears on the right instantly. The tool
walks through your document token by token — tags, text, comments, doctype — instead of
running blunt regular expressions over it, so it can strip <!-- comments -->,
collapse runs of spaces, tabs and newlines, and tidy the whitespace inside tags without
changing what the browser renders. Whitespace that actually matters is left alone:
everything inside <pre> and <textarea> is copied
byte-for-byte, single spaces around inline elements such as
<a>, <span> and <strong> are kept,
and non-breaking spaces are never touched.
Turn on Minify inline <style> CSS to compress embedded stylesheets
too (comments out, spaces around : ; , removed, the last semicolon in each
rule dropped). Inline JSON-LD in <script type="application/ld+json"> is
re-serialised compactly; ordinary <script> bodies are only trimmed at the
edges, because rewriting JavaScript safely is a different job — use the
JavaScript Minifier for that. The aggressive
Remove all whitespace between tags option squeezes out every gap between
elements, which gives the smallest file but can close up spaces you meant to keep between
inline items, so check the preview afterwards.
Minifying a hand-written page typically saves 10–30% of its bytes before gzip even starts. Everything runs in your browser in vanilla JavaScript: your markup is never uploaded, there are no ads, no sign-up and no file size limit beyond what your own device can handle — safe for internal templates, emails and anything with customer data in it.
Frequently asked questions
How do I minify HTML online?
Paste your markup into the left box and the minified HTML appears on the right instantly — no button to press. Comments are stripped, runs of spaces, tabs and newlines are collapsed, and the whitespace inside tags is tidied up. Use the checkboxes to keep comments, turn whitespace collapsing off, minify inline <style> CSS, or squeeze out every gap between tags. Then hit Copy minified HTML or Download .html. You can also load an .html file straight from your device; it is read in the browser and never uploaded.
Does minifying HTML break my page?
Not with the default options. This minifier parses your document into tags, text, comments and doctype tokens rather than running regular expressions over it, so whitespace that the browser actually renders is protected: everything inside <pre> and <textarea> is kept byte-for-byte, single spaces around inline elements like <a>, <span> and <strong> are preserved, and non-breaking spaces are never touched. The one option to test after using is "Remove all whitespace between tags" — it produces the smallest output but can close up gaps you meant to keep between inline items.
How much smaller does minified HTML get?
A hand-written, nicely indented page usually loses 10-30% of its bytes, and template-generated markup with lots of comments can drop further; the Saved percentage above the buttons shows the exact figure for your file. Those savings stack on top of gzip or Brotli compression, so minified HTML still means fewer bytes over the wire and slightly faster parsing. Ordinary <script> bodies are only trimmed at the edges here, so run your JavaScript through the JavaScript Minifier for the rest of the win.