HTML Compressor
Reduce the size of entered HTML by removing unnecessary formatting.
About HTML Compressor
Removing comments and indentation from HTML trims page weight a little and hides internal notes before a snippet is shared or embedded. It is useful for email templates with size limits, widgets pasted into third-party sites, or inline HTML stored in a database field. The result is harder to read, so keep the original for editing.
How it works
Two changes are made. First, every HTML comment between <!-- and --> is removed, including conditional comments used in some email templates. Second, any whitespace that sits between a closing '>' and the next '<' is deleted entirely. Whitespace inside text, inside attributes, and inside inline script or style blocks is left alone, and attributes are not shortened. The ends of the input are trimmed. The output is not validated. It downloads as compressed.html.
How to use HTML Compressor
- Enter the text or data in the format shown in the text box above (Paste HTML to compress).
- Select “Compress HTML” and check the result before copying or downloading it.
Worked example
Paste a nav comment followed by an indented list: '<!-- nav -->', '<ul>', ' <li>Home</li>', ' <li>About</li>', '</ul>'. The output is '<ul><li>Home</li><li>About</li></ul>'. The comment and all line breaks and indentation between tags are gone, while the link labels are unchanged.
Tips for a better result
- Watch inline elements separated only by a space, like '<b>Save</b> <i>now</i>'; the space is removed and the words render joined as 'Savenow'. Add or move the space inside a tag.
- Do not use it on email templates that rely on conditional comments for Outlook, because those comments are deleted too.
- Keep the formatted original under version control and compress only the copy you deploy.
Frequently asked questions
Does it minify inline CSS and JavaScript?
No. Only comments and whitespace between tags are removed. Script and style contents stay as written, apart from whitespace directly between tags. Use a dedicated CSS or JS minifier for those.
Can it break content inside <pre> tags?
Yes. Whitespace between tags is removed everywhere, including inside <pre> and <textarea>, which can change preformatted layouts. Leave those sections out or restore them afterward.
How much smaller will my file be?
It depends on how much indentation and how many comments the source has. Heavily indented templates shrink noticeably, while already-compact HTML barely changes. The tool does not report the saving.
What to check
Test generated markup in your own page. Sanitize untrusted content before inserting it into a live website.
Read the Privacy Policy for information about local processing, connected services and advertising.