</> Online Utilitiesdev.conversiontools.online

HTML Minifier — compress HTML, inline CSS & JavaScript

Paste HTML and get a smaller file, live: comments and wasted whitespace removed, inline <style> and <script> blocks minified, redundant attributes and needless quotes stripped — with the exact byte saving shown before you ship it. <pre> and <textarea> content is never touched.

What to remove

Conditional comments (<!--[if …]>) and important comments (<!--! … -->, used for licenses) are always kept. Attribute quotes are only removed where the value contains no spaces or special characters, so the markup stays valid.

Send minified HTML to…

Carry the current result into the next step of your workflow. Short results travel in the link itself — nothing is uploaded.

Start from an example

One click loads the markup and the option set that suits it — the minified result and its saving appear immediately.

Your session

Versions from this visit, kept only in this tab's memory — step back and forth, pin the ones you want to keep handy, and restore any of them with one click. Nothing here is stored or sent anywhere.

Recent versions

    No versions yet this session — paste HTML or load an example and they will appear here.

    Pinned versions

      No pinned versions yet — pin one above to keep its minified output handy.

      Your tools

      Tools you have actually opened this session, plus any you pin as favorites. The lists live in this browser session only.

      Recently used

        No other tools opened yet this session — tools you visit will appear here.

        Favorite tools

          No favorites yet — pin a tool below.

          All encoding & conversion tools

            How to minify HTML online

            1. Paste your HTML — a full page or any fragment — into the input box. The minified result and byte counts update live.
            2. Toggle what to remove: comments, whitespace, inline CSS and JavaScript minification, redundant attributes, and attribute quotes for the maximum squeeze.
            3. Check the saving, then copy the result or download it as a .html file. Keep your readable original as the copy you edit.

            Worked example

            Input (476 bytes): <!DOCTYPE html> <html lang="en"> <head> <title>My Page</title> <!-- Header styles --> <style type="text/css"> /* Hero banner */ .hero { background : #0b7285 ; padding : 24px ; } </style> </head> <body> <!-- Main content --> <div class="hero"> <h1> Welcome </h1> <p>Hello <b>world</b></p> </div> <script type="text/javascript"> // Greet the visitor var msg = "Hello"; console.log(msg); </script> </body> </html> Output (258 bytes, 218 bytes saved — 45.8% smaller): <!DOCTYPE html><html lang="en"><head><title>My Page</title><style>.hero{background:#0b7285;padding:24px}</style></head><body><div class="hero"><h1> Welcome </h1><p>Hello <b>world</b></p></div><script>var msg = "Hello";console.log(msg);</script></body></html>

            Both documents render identically in a browser. The comments, the type attributes the browser already assumes, the CSS and JS comments, and every indentation space are gone — the markup, text and behaviour are untouched.

            What each option removes

            OptionRemovesNever removes
            Comments<!-- … --> notesConditional <!--[if …]> and important <!--! … --> comments
            WhitespaceIndentation, line breaks, space between tagsContent of <pre>/<textarea>; the single space between words and inline tags
            Inline CSS/* … */ comments and spacing in <style> blocks and style="" attributesAnything inside quoted CSS strings
            Inline JavaScript// and /* … */ comments and extra whitespace in <script> blocksStrings, template literals and regex literals; external scripts with src
            Redundant attributestype="text/javascript", type="text/css", method="get", type="text", type="submit"Any non-default value — type="module", method="post" and friends stay
            Attribute quotesQuotes around values like class="hero" → class=heroQuotes around any value containing spaces or special characters

            Minify, then compress

            Minification and transfer compression do different jobs. Minification deletes bytes outright — comments and indentation are gone before the file leaves the disk. gzip or Brotli then squeezes the patterns that remain. A minified page is also slightly cheaper for the browser to parse. Run this tool first, then let your server compress the result.

            What to do with your minified HTML next

            Minified output is a publishing artifact, not a working file. Save it alongside your readable source, spot-check the page in a browser, and if you need to show the markup as text on a page, run it through the HTML Encoder/Decoder; to check a fragment is well-formed XML, use the XML Formatter. The “Send minified HTML to…” bar above carries the current result into each of those tools for you — and markup those tools send back arrives here ready to minify.

            Frequently asked questions

            What is HTML minification?

            HTML minification removes everything a browser does not need to render the page: comments, indentation and line breaks, extra spaces, and default attributes that repeat what the browser already assumes. The markup, text and behaviour stay identical — only the file gets smaller, so it downloads and parses faster.

            Does minified HTML render exactly the same?

            Yes, when the minifier respects the places where whitespace is significant. This tool never touches the contents of <pre> or <textarea> elements, keeps a single space between words and inline elements in text, and only removes whitespace between tags. Always keep your readable original as the source you edit, and minify a copy for publishing.

            What exactly does this HTML minifier remove?

            You choose: HTML comments (conditional and license comments are kept), collapsed whitespace and line breaks, minified inline <style> blocks and style attributes, minified inline <script> blocks, redundant attributes such as type="text/javascript" and method="get", and attribute quotes where the value needs none. The stats panel shows the exact byte saving for the options you picked.

            Will minifying break my inline JavaScript or CSS?

            The inline minifiers are deliberately conservative: they strip comments and collapse whitespace with full awareness of strings, template literals and regular expressions, and they never rename variables or reorder code. That makes them safe for typical inline snippets. For large or critical scripts, prefer a full build-tool minifier and always test the minified page before publishing.

            Are conditional comments and license comments removed?

            No. Comments that begin with <!--[if (legacy conditional comments) and important comments beginning with <!--! — the convention used for licenses and credits — are always preserved, even with comment removal switched on.

            Should I minify if my server already uses gzip or Brotli?

            Yes — they stack. Compression removes repeated byte patterns from whatever it is given, and minification removes bytes that compression can only shrink, not delete. Minified HTML also compresses slightly better and parses faster. Minify first, then let gzip or Brotli compress the result for transfer.

            Does this tool minify external CSS and JavaScript files?

            No. It minifies the HTML document itself, including <style> and <script> blocks written inline in that document. Linked stylesheets and external scripts (src attributes) are left untouched — minify those files with a CSS or JavaScript minifier before you upload them.

            Why should I keep an unminified copy of my HTML?

            Minified HTML is hard to read, search and debug. Keep the indented original as your source of truth, edit that, and regenerate the minified version whenever you publish — the same workflow as compiled code. The session panel on this page keeps your recent versions one click away while you work.

            Is my HTML uploaded or saved?

            No. Minification happens entirely in your browser as you type; nothing is uploaded, stored or tracked. Session history lives only in this tab's memory and disappears when you close it.

            Related encoding & conversion tools

            About this tool

            The HTML Minifier is one of the free utilities in the Online Utilities Suite at dev.conversiontools.online. Every tool runs entirely in your browser — your code is never uploaded, stored or tracked — so minification is instant and private, and the byte counts you see are measured on the exact text in the box, in UTF-8 bytes.

            Privacy

            This page processes everything locally in your browser: no account, no uploads, and nothing you paste is stored or sent to a server. Advertising on this site is served by Google AdSense, which may use cookies to personalize ads; you can opt out of personalized advertising in your Google ad settings.