HTML Minifier Optimize your HTML code

Highly configurable HTML compressor for smaller file sizes

Input HTML
Minification Options
  • Treat attributes in case sensitive manner (useful for custom HTML tags)
  • Omit attribute values from boolean attributes
  • Don't leave any spaces between display:inline; elements when collapsing. Must be used in conjunction with collapseWhitespace=true
  • Collapse white space that contributes to text nodes in a document tree
  • Always collapse to 1 space (never remove it entirely). Must be used in conjunction with collapseWhitespace=true
  • Use direct Unicode characters whenever possible
  • Parse input according to HTML5 specifications
  • Insert tags generated by HTML parser
  • Keep the trailing slash on singleton elements
  • Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points
  • Minify CSS in style elements and style attributes (uses clean-css)
  • Minify JavaScript in script elements and event attributes
  • Minify URLs in various attributes (uses relateurl)
  • Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break. Must be used in conjunction with collapseWhitespace=true
  • Prevents the escaping of the values of attributes
  • Process contents of conditional comments through minifier
  • Comma-delimited string corresponding to types of script elements to process through minifier (e.g. text/ng-template, text/x-handlebars-template)
  • Type of quote to use for attribute values (' or ")
  • Remove quotes around attributes when possible
  • Strip HTML comments
  • Remove all attributes with whitespace-only values
  • Remove all elements with empty contents
  • Remove attributes when value matches default.
  • Remove type="text/javascript" from script tags. Other type attribute values are left intact
  • Remove type="text/css" from style and link tags. Other type attribute values are left intact
  • Remove space between attributes whenever possible. Note that this will result in invalid HTML!
  • Sort attributes by frequency
  • Sort style classes by frequency
  • Trim white space around ignoreCustomFragments.
  • Replaces the doctype with the short (HTML5) doctype
Select: All, None, Reset
Minified HTML

  About HTML Minification

  Why Minify HTML?

HTML minification is the process of removing all unnecessary characters from HTML source code without changing its functionality. This includes:

  • Removing whitespace characters
  • Stripping HTML comments
  • Collapsing boolean attributes
  • Minifying inline CSS and JavaScript

The primary goal is to reduce the file size, which leads to faster page load times and reduced bandwidth usage.

  Benefits of Minification

Minifying your HTML offers several advantages:

  • **Faster Page Load Times:** Smaller file sizes mean browsers download and render pages quicker.
  • **Reduced Bandwidth Usage:** Less data transferred, which is beneficial for both servers and users (especially on mobile).
  • **Improved SEO:** Search engines consider page speed as a ranking factor.
  • **Better User Experience:** Visitors are less likely to leave a fast-loading site.

Tip: Minification is a crucial step in optimizing web performance. Combine it with image optimization and GZIP compression for maximum impact.

  How to Use This Tool

  1. Paste your HTML code into the "Input HTML" text area.
  2. (Optional) **Adjust minification options** under "Advanced Options" to fine-tune the process. Hover over options for descriptions.
  3. Click the **"Minify HTML"** button.
  4. Your minified code will appear in the "Minified HTML" area, along with **size statistics**.
  5. **Copy** the minified code to your clipboard or **download** it as an HTML file.
  6. **Test thoroughly** after minification to ensure your page functions as expected.

Warning: Be cautious with "unsafe" options like "Remove tag whitespace" as they might lead to invalid HTML, though they offer maximum compression.

  Frequently Asked Questions

Q: Is my code sent to your servers?
A: No! All processing for HTML minification happens locally in your browser. Your code never leaves your device.

Q: Will minification break my HTML?
A: Generally, no. Standard minification should not break your code. However, if you enable certain "unsafe" options, or if your original HTML has errors, issues might arise. Always test the minified output.

Q: Can I reverse minified HTML?
A: Minification is a destructive process in terms of readability. While the functionality remains, restoring the original formatting (indentation, comments, etc.) is not possible. For development, keep a well-formatted version of your source code.

More tools

Obfuscator JS

Minify JS