Paste HTML and get a smaller version with comments and indentation removed, plus a before/after byte count. It runs entirely in your browser, protects the contents of the pre, textarea, script and style elements, and never touches attribute values — so the page still renders the same.
How it works
The minifier strips HTML comments (keeping IE conditional comments), collapses runs of whitespace inside text to a single space, and removes the whitespace-only gaps — the newlines and indentation — between tags. Attribute values are left completely alone, so a doubled space inside an alt or title attribute keeps its exact spacing.
Some elements must not be touched: the raw content of the pre, textarea, script and style elements is protected before anything is stripped, so code blocks, inline scripts and styles survive verbatim. One deliberate limitation: whitespace-only space between tags is removed, which can join adjacent inline elements that relied on that space — for example two bold spans separated by a single space. If your layout depends on such spacing, check the output; otherwise the result is byte-for-byte smaller and visually identical.
Practical examples
An indented template
A nicely-formatted page with lots of indentation and comments shrinks noticeably once the whitespace and comments are gone — often 20–40% smaller with no visible change.
Email HTML
Email templates are verbose and whitespace-heavy. Minifying trims them down before you paste into a sending tool, keeping the script and style blocks intact.
Inlining a fragment
You need to embed an HTML snippet inside a JSON string or a data attribute. Minify it first so it fits on one compact line.
Frequently asked questions
Will minifying change how my page looks?
In almost all cases, no. Browsers already collapse whitespace in text, so removing indentation and comments has no visual effect. The one thing to watch is whitespace between inline elements, which this tool removes.
Are script and style blocks minified too?
No — their contents are protected and left exactly as-is. This tool minifies the HTML structure; use the CSS minifier for styles and a dedicated JS minifier for scripts if you want those compressed.
Is the content of pre and textarea preserved?
Yes. Whitespace is significant inside pre and textarea, so their contents are protected before any collapsing happens and come through untouched.
Does it change attribute values?
No. The tool only processes text between tags, never the inside of a tag, so attribute values keep their exact spacing — including deliberately doubled spaces in alt or title text.
Why did spaces between some elements disappear?
Whitespace-only gaps between tags are removed as part of minifying. For block elements this is invisible, but for inline elements a removed space can join them. If you need the space, add a non-breaking space or keep it inside an element.
Does it keep IE conditional comments?
Yes. Conditional comments that target older Internet Explorer are preserved because they carry rendering logic; ordinary comments are removed.
How much smaller will my HTML get?
Typically 20–40% for hand-written, indented HTML. Already-compact or generated markup shrinks less. The byte counter shows the exact saving for your input.
Can I reverse the minification?
Not automatically — indentation and comments are discarded and cannot be recovered. Keep your source file, or run the output through an HTML formatter to make it readable again.
Is my HTML uploaded anywhere?
No. Everything runs in your browser with JavaScript. Nothing is sent to a server, and it works offline once the page has loaded.
Related tools
CSS Minifier
Minify CSS in your browser — strip comments and whitespace to shrink the file, with a before/after size comparison. Nothing is uploaded.
Developer tools
JSON Formatter
Beautify, validate or minify JSON in your browser — with clear error messages. Nothing is uploaded.
Developer tools
HTML Entity Encoder and Decoder
Encode text to HTML entities or decode named, decimal and hex entities back to characters. In your browser.
Developer tools
Image Compressor
Compress JPG, PNG and WebP images in your browser — adjust quality, resize and convert with a live size comparison, no uploads.
Image tools
Resize Image
Resize JPG, PNG and WebP images to exact pixel dimensions in your browser — lock the aspect ratio or set width and height freely. Nothing is uploaded.
Image tools
PNG to JPG Converter
Convert PNG images to JPG in your browser — with adjustable quality, size comparison and no uploading.
Image tools