HTML Minifier
Paste your HTML and the minified version appears beside it, with the original size, the new size and the percentage saved. You can choose whether to remove comments, collapse whitespace and strip quotes from simple attribute values. Conditional comments for old Internet Explorer are kept, and the text inside pre, textarea, script and style tags is never reflowed. Everything runs in your browser and your code is not uploaded.
Removed 2 comments.
Minifying HTML removes characters the browser does not need, so the file is smaller to download. The savings are usually modest because servers already compress text with gzip or Brotli, so treat minifying as a small extra. This tool uses a simple tokenizer, not a full HTML parser: it does not minify the CSS or JavaScript inside style and script tags, and it does not fix invalid markup. Check the result in a browser before you ship it, especially for pages that depend on spaces between inline elements. Everything runs in your browser and your code is not sent anywhere.
Related Tools
[5 suggestions]CSS Minifier and Beautifier
Minify CSS to cut its size, or beautify minified CSS into readable, indented code. Shows the bytes saved, and keeps strings, urls and calc() spacing safe.
Developer & WebHTML to Markdown Converter
Convert raw HTML markup or webpage snippets into clean, readable Markdown syntax instantly.
Format ConversionMarkdown to HTML Converter
Convert Markdown syntax to clean, semantic HTML with instant live code output and visual rendered preview.
Format ConversionXML Formatter and Validator
Format, minify and validate XML. Errors show the line and column, and the text inside your elements is never changed.
Developer & WebJSON Formatter
Validate, pretty-print, and minify JSON with clear error reporting for invalid input.
Developer & WebAbout the HTML Minifier
Minifying HTML removes characters that the browser does not need to build the page. The tool removes comments, collapses runs of spaces and line breaks into a single space, drops the spaces between block-level tags such as div, p and li, tidies the spacing inside tags and, if you choose, removes the quotes around values such as class=btn. It keeps one space between inline elements, because browsers show that space, so a b and an i side by side still have a gap. The sample page is 432 bytes before and 279 after, a saving of 35.4%. Real savings depend on how much indentation and how many comments the source has. Servers usually compress text with gzip or Brotli as well, which already removes much of the same repetition, so minifying is a small extra on top. This is a simple tokenizer and not a full HTML parser: it does not minify the CSS or JavaScript inside style and script tags, and it does not repair invalid markup. Always check the result in a browser.
What does an HTML minifier do?▾
It removes comments, extra whitespace and other characters the browser does not need, so the file is smaller to download without changing how the page looks.
Is minified HTML safe?▾
Usually, but whitespace can matter. This tool keeps a single space between inline elements and never touches pre, textarea, script and style content. Test the result in a browser.
Does it minify CSS and JavaScript?▾
It only trims the whitespace around the content of style and script tags. Use a CSS minifier or a JavaScript minifier for the code itself.
Is it worth minifying if my server uses gzip?▾
The gain is smaller, because compression already removes repeated whitespace, but minified HTML is still a little smaller and cheap to produce.
Is my code uploaded?▾
No. The minifying runs in your browser and your HTML is not sent anywhere.