When to use it
Use this tool to shrink an HTML page by removing comments, extra spaces and line breaks. It is useful for hand-written websites, landing pages, HTML email templates that must stay under size limits, and snippets pasted into website builders that limit how much code you can add.
How to use it
- Paste your HTML into Your text, or click Example to see a sample page.
- Choose the options:
- Remove comments deletes
<!-- … -->notes. - Minify CSS in
<style>tags also shrinks the CSS inside the page.
- Remove comments deletes
- The Minified HTML appears immediately, with the old size, new size and percentage saved.
- Click Copy result, or Download .html to save the file.
Worked example
The example page has indentation, a style block, a navigation menu with a comment, a pre block and a paragraph with extra spaces. It is 357 bytes before and 252 bytes after, 29% smaller.
Look at what changed. The <!-- Navigation --> comment is gone. Inside the style tag, color: #333333 becomes color:#333. The two links in the menu keep one space between them, so they do not run together on screen. The text inside the pre tag, keep this spacing, is left exactly as it was, because pre shows spaces as they are typed. In the paragraph, Hello world becomes Hello world, which is how a browser shows it anyway.
What stays the same
The minifier never changes your text, links, attributes or the order of elements. It only removes characters the browser ignores, so the page looks and works the same. Search engines read minified HTML just as well as the original, so it has no effect on SEO apart from making pages load a little faster.
Tips
- Keep the readable version. Edit the original, then minify again before you publish.
- Check email templates in a test send. Some email clients are picky, so preview the minified version before sending to a list.
- Combine with server compression. Gzip or Brotli on your server makes HTML smaller still.
- Minify scripts separately. Run JavaScript through the JS Minifier and CSS files through the CSS Minifier.
Common mistakes
- Expecting a big change on small pages. Savings depend on how much indentation and how many comments there are.
- Removing comments a system needs. Conditional comments in old email templates are a common example.
- Editing the minified file by hand. One long line of HTML is hard to change safely.