HTML Minifier
An HTML minifier shrinks markup by collapsing whitespace and removing comments without changing how the page renders. Paste or drop HTML, keep the safe defaults, then copy or download the minified file and see the bytes saved. Spaces between inline words stay; <pre>, <textarea>, <script>, and <style> bodies are kept. Nothing is uploaded.
Updated
This page runs a small zero-dependency HTML tokenizer in your tab. Text whitespace collapses to one space and is removed only where it touches a block-level tag (div, p, li, table, head, meta…) or the document edge — so "Hello <b>world</b>" never turns into "Helloworld". Ordinary <!-- comments --> go; <!--[if mso]> conditional comments for Outlook email and <!--! license --> comments stay by default. Attribute values, entities like &nbsp;, and inline SVG casing (viewBox) are copied as written. On a pretty-printed 1.8 MB Wikipedia article saved on 8 Oct 2026, the default settings cut the file to about 830 KB (≈54% smaller) with the same visible word sequence.
Inline code is handled conservatively. <pre> and <textarea> bodies are verbatim. <script> and <style> bodies are only trimmed at their edges unless you opt in: JSON-LD / JSON scripts can drop whitespace outside strings (validated with JSON.parse first, numbers untouched), <style> can get a conservative CSS squeeze, and inline JavaScript can lose indentation while keeping every newline. This is not Terser, not a CSS optimiser, and not an HTML validator — it does not rename variables, rewrite markup, or fix broken tags. Nothing is fetched, uploaded, or written to localStorage.
Paste a full HTML document or a fragment, or drop an .html file. Minifies as you type — nothing leaves this tab.
Optional .html / .htm drop. Read with FileReader — never uploaded.
Minified HTML
<pre> and <textarea> stay verbatim; <script> and <style> bodies are only trimmed unless you tick the inline options. Not Terser or a CSS optimiser. Closing the tab drops the workspace — nothing is uploaded or written to localStorage.
How does the HTML Minifier work?
1. Paste or drop HTML
Paste a full document or a fragment, drop an .html file, or press Load example for a small fictional order page. The file is read with FileReader in this tab — never uploaded.
2. Keep or adjust the options
Safe defaults: collapse whitespace, remove comments but keep conditional and license comments, collapse boolean attributes, and minify JSON-LD. Turn on attribute-quote removal, inline CSS, or inline JS indentation trim only if you want the extra bytes.
3. Check the savings
The status line shows original and minified size in UTF-8 bytes, bytes saved, the percentage, and how many comments were removed. Notes list anything left as written, such as an unclosed tag or invalid JSON-LD.
4. Copy or download
Copy the minified HTML or download it as a .min.html file. Spot-check the page in a browser before you ship. Closing the tab drops the workspace.
Questions about HTML Minifier
- What does an HTML minifier do?
- It removes bytes the browser does not need: runs of spaces, tabs, and newlines between tags, ordinary HTML comments, and redundant attribute syntax such as checked="checked". The page should render the same, but the file is smaller and transfers faster. This minifier works on the HTML text itself — it does not bundle assets, rename JavaScript variables, or rewrite your markup structure.
- Will minifying HTML break my layout or join words together?
- Not with the default settings. Whitespace is collapsed to a single space and only removed next to block-level tags (div, p, li, table, head tags) or at the document edge, so spaces between inline elements like <a>, <span>, <strong>, and plain text are kept. If your CSS turns list items or divs into inline-block and relies on the gap between tags, tick Conservative to keep one space everywhere. Elements styled with white-space: pre in CSS are not detected — wrap that text in <pre> or minify it separately.
- Is it safe for <pre>, <textarea>, <script>, and <style>?
- Yes. <pre> and <textarea> bodies are copied verbatim, including indentation and newlines. <script> and <style> bodies are only trimmed at their edges by default, so // comments, regex literals, and template strings are never broken. Non-JavaScript script types such as text/template stay untouched. The optional inline CSS and JS settings are deliberately conservative and say so — use Terser or a CSS minifier in your build if you need full code minification.
- Does it keep Outlook / IE conditional comments for HTML email?
- Yes, by default. Comments that start with [if …] or end with <![endif] (the <!--[if mso]> pattern used in email templates) are kept, and so are <![if !mso]> blocks and license comments that start with <!--!. Untick Keep conditional comments if you are minifying a normal web page and want them gone too.
- Should I remove attribute quotes?
- It is off by default. HTML allows unquoted values only when they contain no spaces, quotes, =, <, >, or backticks, so the option drops quotes just from values like id="main" and leaves class="a b" or URLs ending in / quoted. It saves a few bytes per attribute but makes the markup harder to read and is invalid in XHTML or XML. Gzip or Brotli already compresses quotes well, so most sites leave this off.
- How much smaller will my HTML get?
- It depends on how the file was written. Hand-indented templates and pretty-printed exports shrink the most — a pretty-printed Wikipedia article went from about 1.8 MB to 830 KB in our 8 Oct 2026 test. Pages that a framework already minified may save under 1%. The status line shows exact UTF-8 bytes before and after. Server compression (gzip/Brotli) reduces both versions further, so the transfer saving is smaller than the raw-byte saving.
- Does it upload my HTML or run my scripts?
- No. Minification is plain string processing in this tab. Nothing is posted to Page Utils, nothing is written to localStorage, scripts in your markup are never executed, and images or stylesheets it references are never fetched. Closing the tab drops the text.
- How is this different from HTML Formatter, and is there a /minify-html/ URL?
- HTML Formatter is for reading markup — it pretty-prints with indentation (its compact mode is a quick squeeze). HTML Minifier is the dedicated minify-first page with layout-safe whitespace rules, comment controls, and byte stats. There is one canonical address, /developer/html-minifier/; searches like minify html or html minify land here. We do not publish alias slugs that would split the address.
What else can I open?
- JWT Token DecryptDecrypt a compact JWE locally with Web Crypto.
- Flexbox GeneratorBuild a CSS flexbox layout visually with a live preview, then copy the CSS or Tailwind classes.
- YAML FormatterPretty-print and validate YAML in the browser — keeps YAML as YAML, nothing uploaded.
- HTML FormatterBeautify or minify HTML in your browser.
- CSS FormatterPretty-print or minify CSS locally in the browser.
- JavaScript FormatterBeautify or minify JavaScript locally in the browser.
These tools run in your browser. Page Utils does not store, upload, or write to localStorage the keys, tokens, or text you paste. Results are a convenience aid, not legal, tax, or security advice.