ToolStudio.es
In your browser1 Free Trial

Minify HTML online

Remove comments, whitespace and redundant code from your HTML without changing how the page renders.

Free try: process 1 file or text. With Pro, unlimited use and several files at once.
Options
Input
Processed in your browser: your code is never uploaded.
Free: 1 file or text. Several at once with Pro.
Result

What does an HTML minifier do?

HTML written by people, or generated by a CMS or a template engine, is full of things the browser does not need: indentation, line breaks between tags, developer comments, attributes that just repeat the default value and quotes that are optional. Minifying removes all of that so the file that travels over the network is smaller and the browser has less to parse.

This tool uses html-minifier-terser, the same engine used by many build pipelines. You choose what to apply: remove comments, collapse whitespace, minify inline CSS (in <style> blocks and style="" attributes) and inline JavaScript (in <script> blocks), remove redundant attributes and use the short <!doctype html>, and remove the quotes around attribute values where HTML allows it. Whitespace inside <pre> and <textarea> is kept, because there it is part of the content.

What does not change is the result on screen: the same elements, the same text and the same behaviour. After running it you see the size before and after and the percentage saved, so you know whether it was worth it. Minification matters most on pages that are not minified by a build step, such as static landing pages, email templates, HTML exported from a page builder or snippets you embed in another site.

Everything runs in your browser: the HTML is never uploaded to a server. You get one free try per tool: one file or one pasted text. After that you can still re-process the same text with different options, but new input needs ToolStudio Pro, which gives unlimited use of every tool, several files at once downloaded together in a ZIP, and no ads. You can cancel anytime.

How to minify HTML

  1. Paste your HTML in the input box or drop an .html or .htm file.
  2. Choose the options: comments, whitespace, inline CSS and JS, redundant attributes, optional quotes.
  3. Run the minifier and check the size before and after and the percentage saved.
  4. Copy the result or download it as a file.

When to minify HTML

  • Static landing pages published without a build tool.
  • HTML email templates, where some clients clip large messages.
  • Pages exported from a page builder or a CMS with lots of comments.
  • HTML snippets and widgets you embed in other websites.
  • Checking how much weight a template could lose before adding minification to your build.

Minify vs gzip: do I need both?

Gzip and Brotli compress the file while it travels and the browser decompresses it on arrival. Minification removes characters for good. They work well together: minified HTML compresses to a smaller size than the original, and the browser also parses fewer bytes after decompression. If your server already compresses, minifying still helps, just with a smaller gain than the raw percentage suggests.

What to watch out for

  • Collapsing whitespace can remove a visible space between inline elements, for example between two <span> or <a> tags written on separate lines. Check the result if your layout depends on it.
  • Removing comments also removes conditional comments and template markers. Keep them off if another tool reads them.
  • Inline JavaScript with syntax errors cannot be minified; the error message from the parser tells you where the problem is.

Frequently Asked Questions

Does minifying HTML change how the page looks?

It should not. Only code the browser ignores is removed. The one case to check is whitespace between inline elements, which collapsing can reduce to a single space or remove.

Is the whitespace inside <pre> and <textarea> kept?

Yes. In those elements spaces and line breaks are part of the content, so the minifier leaves them as they are.

Does it minify the CSS and JavaScript inside the HTML?

Yes, if you turn those options on: CSS in <style> blocks and style attributes, and JavaScript in <script> blocks. For separate files use the CSS minifier and JavaScript minifier.

Is my HTML uploaded anywhere?

No. The minification runs entirely in your browser and the code never leaves your device.

Is it free?

You can minify one file or one pasted text for free. After that you can keep changing options on the same text, but new input needs ToolStudio Pro, which gives unlimited use, several files at once in a ZIP and no ads.

Related tools

Development

CSS Minifier

Minify CSS online with structural optimisation that merges rules and declarations. See the bytes saved, all in your browser.

CSSMinify
Try this tool
Development

JavaScript Minifier

Minify JavaScript online with Terser: remove dead code, shorten variable names and drop console calls, all in your browser.

JavaScriptJSMinifyTerser
Try this tool
Development

HTML Formatter

Format messy or minified HTML into clean, indented code, including embedded CSS and JavaScript. Runs in your browser.

HTMLBeautifyPrettier
Try this tool
Development

SVG Optimizer Pro

Shrink SVG vector assets by stripping editor metadata, reducing coordinate decimals, and removing unused groups and IDs without losing visual quality.

SVGWeb
Try this tool
Images

Image Compressor & Resizer

Compress JPG, PNG, WebP and AVIF at the quality you choose, resize by pixels or percentage and save in another format. All in your browser, without uploading the images.

JPGPNGWebPAVIF
Try this tool