How to use the HTML Minifier
- 1. Paste your HTMLPaste a full page or a fragment.
- 2. Choose optionsRemove comments, collapse whitespace, minify inline CSS and JS, drop default type attributes.
- 3. MinifyCopy the result or download the .html file and see the saving.
Why whitespace is tricky
In HTML, spaces between inline elements are visible: <b>Python</b> and <b>SQL</b> needs the space before and. The minifier collapses runs of spaces and line breaks to a single space, and removes whitespace only between tags where it can't show, such as between <head> elements or block elements. Content inside <pre> and <textarea> is left exactly as written. Inline <style> and <script> blocks go through our CSS and JavaScript minifiers. Your code is processed in your browser and never uploaded.
We tested it on 31 pages, mostly our own tool pages plus an edge-case page: screenshots of the original and minified pages were pixel-identical, with the same visible text.
Worked example
The sample page has a comment, an indented head, an inline style block, a hero section, a <pre> block and an inline script. Minified, it goes from 600 B to 421 B, 29.8% smaller. The style block becomes body{font-family:system-ui,sans-serif;margin:0px}…, the space between Python and and survives, and the <pre> block keeps all its spacing.
Good to know
- Conditional comments and server templates such as
<?php ?>are better minified on your build server. - Attribute quotes are kept, so the output stays valid and easy to diff.
- Minify a copy; keep the readable version for editing.
Frequently asked questions
Will it change how my page looks?
No. Only whitespace that can't render and comments are removed, and the test pages rendered identically.
Does it remove optional closing tags?
No. That saves little and makes the HTML harder to read and debug.
Is the HTML minifier free?
Yes. You can open the HTML minifier, paste code and change every setting without signing up. When you minify HTML for the first time, we ask once for your name and WhatsApp number; after that it, and every other Uncodemy tool, opens straight away.