HTML Minifier
Minify HTML safely: remove comments and extra whitespace while keeping scripts, styles and <pre> intact.
HTML Minifier
Paste code, choose a file or drop one here (up to 3.00 MB). Everything runs in your browser — the code isn't uploaded or run.
Your data is processed locally in your browser and is not uploaded to OZVILO servers.
How to use the HTML Minifier
- 1Paste HTML, choose an .html or .htm file, or drop one onto the box.
- 2Pick options: comments, conditional comments, whitespace and redundant type attributes.
- 3Press Minify HTML and check the original size, minified size and percentage saved.
- 4Copy the result or download it as .html.
Examples
Indented page
- Input
- <p> Hello <b>world</b> </p>
- Result
- <p>Hello <b>world</b></p>
Inline script
- Input
- <script> console.log("a b"); </script>
- Result
- Kept exactly as written
HTML Minifier features
- Removes comments (keeps conditional comments and <!--! notices if you like)
- Collapses whitespace in text, keeping the spaces that separate words and inline elements
- Never changes <script>, <style>, JSON-LD, <pre>, <textarea> or attribute values
- Built-in safety check: the result must parse to the same elements, attributes and text
- Original and minified size, bytes saved and percentage; runs in your browser
Frequently asked questions
Can minifying break my page?
The tool only removes comments and whitespace that doesn't render, and checks that the result has the same elements, attributes and text before showing it. One thing to know: removing whitespace around block elements can close the small gap between elements you've styled as inline-block — turn that option off if you rely on it.
Does it minify the CSS and JavaScript inside my HTML?
No. Inline <script> and <style> blocks are kept exactly as written, which avoids breaking them. Use the CSS Minifier and JavaScript Minifier for separate files.
Is my HTML uploaded?
No. Minification runs in your browser, and the HTML is never executed.
How much will my pages shrink?
It depends on how much indentation and how many comments the HTML has; the tool shows the exact saving for your file. Servers that use gzip or Brotli compression already shrink repeated whitespace a lot, so the saving in transfer size is usually smaller.
Related tools
- Available
CSS Minifier
Minify CSS without rewriting it: strip comments and whitespace, keep variables, media queries and fallbacks.
SEO ToolsOpen tool - Available
JavaScript Minifier
Minify modern JavaScript and ES modules with Terser, with optional name shortening and source maps.
SEO ToolsOpen tool - Available
Page Size Checker
Measure a page's HTML, CSS, JavaScript, images and fonts — transfer and uncompressed sizes reported separately.
SEO ToolsOpen tool - Available
Website Speed Checker
Test a page's speed with Google PageSpeed Insights: performance score, lab metrics and improvement opportunities.
SEO ToolsOpen tool