Sign up free

Online HTML Minifier and Compressor

Shrink HTML by removing comments and extra whitespace, and see how much smaller it got.

About HTML Minifier

An HTML minifier trims what browsers don't need from a page: comments, indentation and the space around tags. Use it before you publish a static page, paste a snippet into a CMS field or an ad slot with a size limit, or send out an HTML email template. Paste the code or open a file, and the minified version appears as you type, with the size before and after and the percentage saved.

Comments are removed, except IE conditional comments, which older templates still rely on. Runs of whitespace shrink to one space, the space around block tags such as div and p goes, and one space stays between inline elements. Text in pre and textarea is left alone. Inline CSS and JavaScript are minified too, by the same safe rules as our CSS and JavaScript minifiers; untick Also minify inline CSS and JavaScript to leave them as written. Gzip or Brotli on your server saves more on top, and the GZIP and Brotli Checker shows whether it's on. Nothing is uploaded.

How to use HTML Minifier

  1. 1
    Paste the HTML

    Paste the code into the box or open an HTML file.

  2. 2
    Keep or skip inline code

    Also minify inline CSS and JavaScript is on, so untick it to leave script and style blocks as they are.

  3. 3
    Check the savings

    The HTML minifier shows the result live, with the size before and after.

  4. 4
    Copy or download

    Copy the minified HTML or download it as a file.

Why use Cubfile for this

  • Comments removed

    HTML comments are removed, while IE conditional comments stay.

  • Whitespace collapsed

    Indentation and line breaks go, pre and textarea keep their spacing, and inline elements keep the space between them.

  • Inline CSS and JS too

    Style and script blocks are minified with the same safe rules, or left as written if you untick the option.

  • Size saved

    See the size before and after and the percentage saved before you copy.

FAQ

HTML Minifier: questions and answers

Will minifying HTML break my page?
Usually not. Text in pre and textarea keeps its spacing, a space stays between inline elements such as links and bold text, and inline CSS and JS go through the same safe minifiers as our CSS and JavaScript tools. Check the page once afterwards anyway. The HTML Formatter indents minified markup again if you need to edit it later.
Does the HTML minifier remove comments?
Yes, except IE conditional comments, which some older templates still use to load files for Internet Explorer.
Can it minify inline CSS and JavaScript too?
Yes, and it does by default. Untick Also minify inline CSS and JavaScript to leave style and script blocks as written.
How much smaller will my HTML get?
It depends on how much indentation and commenting the page has. The size before and after and the percentage saved appear with the result, and gzip or Brotli on your server saves more on top.
Is my HTML uploaded when I minify HTML online?
No. Minifying runs in your browser, doesn't use any daily tasks and needs no sign-up.
Share HTML Minifier with a friendIt runs in any browser, and they can try it without signing up.

Related tools

HTML HTML FormatterIndent messy HTML so it’s easy to read.
JS JavaScript FormatterBeautify minified or messy JavaScript.
HEX Color ConverterConvert colors between HEX, RGB, HSL and CMYK, and check contrast.
CRON Cron Expression GeneratorBuild cron expressions and see the next run times in plain words.
CSS CSS FormatterTurn minified CSS into neat, readable rules.
CSS CSS MinifierMinify CSS to load faster.
HTTP HTTP Request TesterSend GET, POST and other requests to a public API and read the response.
JS JavaScript MinifierStrip comments and whitespace from JavaScript without changing how it runs.