HTML Minifier
Minify HTML in your browser by removing comments and extra whitespace, then copy or download the compact result.
On this page
Pasting markup like <button type="submit" disabled="disabled">Join</button> into the HTML Minifier and clicking Minify HTML returns <button type=submit disabled>Join</button>. The quotes drop because they carry nothing here, and the repeated boolean value collapses to a bare word. The button still submits and still starts out disabled. Everything runs in your browser, so nothing you paste is uploaded anywhere.
Minify HTML without changing how it renders
The minifier reads the document as a stream of tags, text nodes, comments, and doctypes, then writes back only the characters the browser needs. The 1278-character sample loaded on this page comes out at 950 characters, saving 328 characters or roughly a quarter of the file. Pages with heavy indentation and long comment banners often shrink further.
Whitespace handling is context aware. Runs of spaces and newlines between block level tags disappear completely. Between inline elements the run collapses to the single space that keeps them visually apart, because deleting it would change what visitors see.
Eight controls shape the output
Seven checkboxes under Minify options start switched on. Collapse whitespace trims spacing between tags. Remove comments deletes <!-- --> blocks. Unquote safe attributes drops quotes when a value holds no spaces or special characters. Collapse boolean attributes turns required="required" into required. Remove default type attributes strips type="text/javascript" from scripts and type="text/css" from stylesheets while leaving values such as type="module" alone. Minify inline CSS compresses style blocks and style attributes with the same ruleset the CSS Minifier uses. Use short doctype replaces any older declaration with <!DOCTYPE html>.
Strip optional end tags is off by default. Switch it on to drop closers such as </li> and </p> where the HTML grammar allows omission and only when another tag follows immediately.
The Live checkbox reruns the tool as you type; turn it off and results update when you press Minify HTML again. Load example refills the editor with the built-in sample, and Clear empties both cards.
Where spaces stay
Not every space is removable. The gap between </label> and its <input> survives because inline elements need it to render correctly. Values containing spaces keep their quotes, so class="page pricing" stays quoted while action="/signup" loses them safely. Inside minified CSS the compressor protects strings and url() data, and leaves calc() expressions spaced, so padding:calc(24px + 2vh) 16px stays valid.
Script contents pass through exactly as written. Rewriting JavaScript without a full parser risks breaking regular expressions or automatic semicolon insertion, so a script block keeps its line breaks and indentation. Comments wrapped in Internet Explorer conditionals survive untouched too, and the tool prints a reminder of these guarantees right under the options.
Beautify mode rebuilds the indentation
Switching Mode to Beautify reverses direction. The document reprints with one indent step per nesting level, set to 2 spaces, 4 spaces, or a tab under Indent. Inline runs flow together on one line while block elements each start a fresh row, and comments get a line of their own. Attributes keep their original quotes in this mode, since beautified markup exists for reading and editing. Download saves the pretty version as formatted.html instead of minified.html.
Wrap at column works in both modes. Enter a number such as 60 and long lines break only at block boundaries where a newline renders as nothing, never between two inline tags where the break would appear as visible space.
Reading the size report
The row under the result shows three figures. For the sample input it reads Original 1278, Result 950, Saved 328 chars (25.7%). The percentage climbs quickly once comment banners and blank lines are gone. After processing, Copy places the result on the clipboard and Download hands you a ready-to-deploy file.
Worked examples
A comment and four levels of indentation vanish. The input
<!-- Page header -->
<section class="hero">
<h1>Ship faster</h1>
<p>Everything you need is included.</p>
</section>
becomes
<section class=hero><h1>Ship faster</h1><p>Everything you need is included.</p></section>
123 characters become 89, and the section still renders identically.
Boolean attributes collapse alongside classic type declarations. The input <input type="email" name="email" required="required"> becomes <input type=email name=email required>, three attributes shorter with no behavioral difference.
An inline stylesheet sheds its comment and decoration. The input <style>.hero { padding: 48px 24px; }</style> becomes <style>.hero{padding:48px 24px}</style>, keeping the space inside the shorthand value that separates its two lengths.
Anything inside pre passes through byte for byte, so code listings embedded in a page keep their shape after minification.
Why the browser does all the work
Minification happens in the current tab with no network request, so unreleased landing pages, email templates, and internal prototypes never leave your machine. Open file loads a local .html or .htm document straight into the editor and reports its size; editing afterwards marks the state so you always know what produced the result. The compact output sits beside the input from the moment the page opens, ready to copy or download.