Quick Answer
An HTML minifier removes everything that a browser does not need — comments, extra whitespace between tags, and unnecessary blank lines — producing a smaller file that renders identically. This tool shows the before and after sizes live so you can see exactly what you save.
What This Tool Does
Paste HTML and the tool strips <!-- comments -->, collapses runs of whitespace between tags, and trims around text content. The output is smaller, loads faster over slow connections, and looks the same in the browser. It is deliberately conservative: attribute values and visible text are preserved exactly.
Key Features
- Live size comparison — input KB, output KB, and percentage saved update as you type.
- Comment removal — developer notes and conditional comments are dropped.
- Whitespace collapsing — the space between
>and<is removed where it is safe. - Advanced options — remove optional tags, empty attributes and empty elements, collapse boolean attributes, strip attribute quotes, and more.
- Inline CSS/JS minification — compress
<style>and<script>blocks in one pass. - Upload file or load from URL — read a local
.htmlfile or fetch a page directly. - Safe by design — text content, attribute values, and
<pre>-like spacing are not destroyed.
How to Use the HTML Minifier
- Paste your HTML into the input box (or load the Sample, Upload File, or a URL).
- Open Show advanced options and tick the optimizations you want — most are off by default except comment and whitespace removal.
- Read the minified result on the right and the size stats above the buttons.
- Click Copy to put the minified HTML on your clipboard.
- Click Download to save it as
index.min.html.
Advanced Options Explained
- Remove optional tags — drops
<html>,<head>,<body>and table-section tags that browsers infer. - Collapse boolean attributes — turns
disabled="disabled"intodisabled. - Remove attribute quotes — removes quotes around simple attribute values where valid.
- Minify inline CSS / JS — runs a local minifier over
<style>and<script>contents. - Remove script/style type attributes — strips redundant
type="text/javascript"andtype="text/css". - Max line length — keeps each line under a limit so the output stays diff-friendly.
- Use short doctype — replaces any doctype with the HTML5
<!DOCTYPE html>.
Use Cases
- Shrinking email templates that must stay under a size limit.
- Preparing a single-file HTML demo to share with teammates.
- Reducing payload size for inline HTML in a CMS or a webview.
Tips
- Minified HTML is harder to read — keep the pretty version in source control and minify at build time.
- If a page renders differently after minification, check for
<pre>blocks or inline scripts where whitespace mattered. - For real projects, pair this with a build tool (Vite, Parcel, webpack) so minification happens automatically.
Privacy
Minification is local — your markup never leaves the browser, so templates containing internal URLs or credentials are safe to paste.
Conclusion
Every byte counts on slow networks. Paste, copy the smaller file, and ship it — free and private.