Minify HTML
Compress HTML documents — whitespace and comments stripped, inline CSS and JS minified too — entirely in your browser.
Last updated
How to use minify html
- Paste HTML into the input box, or tap Load file to read an .html file from your device.
- Press Minify HTML. The first run downloads the minifier (~600 KB, then cached); later runs are instant.
- The size readout shows bytes before, bytes after and the percentage saved.
- Copy the result or download it as a .min.html file. Keep your formatted source — minified markup is unpleasant to hand-edit.
Examples
Minify a small page
A complete document with comments and indentation collapses to a single dense line of markup.
Inline CSS gets minified too
The <style> block inside the page is compressed with the same whitespace and color shortening as standalone CSS.
What is Minify HTML?
HTML is surprisingly verbose once a page leaves a templating system: indentation from the template, comments from the team, attributes a browser would assume anyway. Minifying HTML collapses that back down — whitespace runs become single spaces or nothing, comments disappear, redundant attributes like type="text/css" are dropped, and boolean attributes shrink to just their name. The document a browser builds from the minified markup is the same DOM.
This HTML minifier goes one step further than most: inline <style> blocks are passed through a CSS minifier and inline <script> blocks through a JavaScript minifier, so a self-contained page gets fully compressed in a single pass. Paste markup or load an .html file, and the tool reports exactly how many bytes were saved.
A word of caution that experienced developers already know: whitespace inside <pre>, <textarea> and a few other elements is meaningful, and a careful minifier preserves it — this one does. Even so, minify a copy and keep the readable original under version control. And since processing happens on your machine, unpublished pages and client work stay private.
Frequently asked questions
Is it possible to minify HTML without breaking the page?
Yes, as long as the minifier respects the elements where whitespace matters. This tool collapses whitespace in normal flow content but preserves it inside <pre>, <textarea> and similar elements, and it never reorders attributes or rewrites URLs. The rendered page is unchanged; only the byte count drops.
How can I minify my HTML code online?
Paste the markup into the box above (or load the .html file) and press Minify HTML — the result appears instantly with the exact savings. Everything runs in your browser, so the page source never touches a server. For whole sites, the same class of minifier usually runs as a build-step plugin.
What is minify in coding?
Minification means transforming source code into the smallest form that behaves identically: comments, indentation and dead code removed, values shortened. It is standard practice for anything delivered to a browser because smaller files download faster. It is not encryption or obfuscation — the logic is still there for anyone to read.
Does it also minify inline JavaScript and CSS?
Yes. Inline <script> blocks go through a JavaScript minifier (terser) and inline <style> blocks through a CSS minifier (clean-css) as part of the same pass. Linked external files are left alone — minify those separately with the dedicated CSS and JavaScript tools.
How much smaller does HTML get?
Markup-heavy documents typically shrink 10–25%, and pages with large inline style or script blocks can go much further. Server compression (gzip or brotli) stacks on top, so minified HTML compresses better too. The readout here shows your exact numbers.
Related tools
- Minify CSS
Minify CSS stylesheets locally — comments, whitespace and redundant units removed, exact savings shown.
- XML Formatter
Quickly format and validate XML with your chosen indentation.
- Base64 Encode/Decode
Quickly encode text to Base64 and decode Base64 back to readable text.
- JSON Formatter
Pretty-print, validate and minify JSON with helpful error messages.
- Minify JavaScript
Minify JavaScript with terser — comments, whitespace and dead code removed, names shortened, all locally.
- JSON Minifier
Minify JSON to one compact line locally — validates first and shows the exact bytes saved.
Browse all developer tools.