Code Tools

HTML Minifier

All tools

Remove comments and the whitespace between tags to get a compact single-line copy of your HTML.

How it works

Four simple steps

1

Paste the markup

Add a template, snippet or email body, or drop an .html file.

2

Comments removed

Every <!-- --> block is deleted automatically.

3

Whitespace collapsed

Runs of spaces shrink to one and gaps between tags disappear.

4

Copy or download

Copy the single line or save it as min.html.

HTML Minifier

About HTML Minifier

You are pasting a block of markup into a CMS field or an email builder that mangles line breaks, or you just want to trim a few kilobytes from a static page. A quick minify pass gives you a one-line version.

The HTML Minifier performs three steps. It deletes every <!-- --> comment, collapses any run of whitespace (spaces, tabs, newlines) into a single space, and removes whitespace sitting between a closing > and the next <. The output updates while you type and can be copied or saved as min.html. It does not remove optional tags, shorten attributes or optimize embedded CSS and JavaScript beyond whitespace.

Because the whitespace rule is applied everywhere, content inside <pre> and <textarea> loses its line breaks, and inline scripts that rely on line breaks or // comments can stop working. Conditional comments for older Outlook versions are removed as well, which matters for email templates. Keep those blocks out, or reinsert them afterwards. Embedded styles and scripts are better handled separately by the CSS minifier and the JS minifier, and keep a readable source you can regenerate with the HTML Formatter.

Minification is a few regular expressions applied in the browser, so unpublished pages never leave your device.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

It depends on how much indentation and how many comments the source contains. Deeply indented templates shrink noticeably, while markup that is already compact barely changes.

For small pages and snippets, yes. Build-time minifiers can also drop optional closing tags, collapse boolean attributes and compress inline assets, which this tool does not attempt.

View more FAQs

Related tools

View all

HTML Formatter

Beautify and indent HTML markup.

Open

CSS Formatter

Format and pretty-print CSS.

Open

JS Formatter

Beautify JavaScript code.

Open

JSON Formatter

Beautify and validate JSON.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools