lobsite! Sign in Sign up

Free tools /

HTML Minifier

Minify HTML by removing comments and extra whitespace, with inline CSS and JavaScript minified too. See how many bytes you save. Free, in your browser.

HTML formatter →
Minified
Free, no account. It stays up for 6 hours, or for good once you keep it.

How to use it

  1. Paste your HTML, open an .html file, or start from the sample.
  2. The minified HTML appears as you type, with the size before and after.
  3. Copy it, download it, or press Publish this page to put it online.

What it removes

  • Comments, and whitespace between tags (a single space is kept where it could show between inline elements).
  • Attributes that only repeat the default, like type="text/javascript" on scripts and type="text/css" on styles.
  • The long doctype, replaced with <!doctype html>.
  • Inline <style> and <script> contents are minified as CSS and JavaScript.

<pre> and <textarea> keep their whitespace, so the page looks and works the same.

Is it worth it?

Most hosts, Lobsite included, already compress pages with gzip or Brotli on the way to the browser, which shrinks repeated whitespace very well. Minifying first usually saves a further 5 to 15%. It matters most for large pages, pages with a lot of inline CSS and JavaScript, and HTML inside emails, where nothing is compressed.

Frequently asked questions

Can minifying break my page?

The settings are the conservative ones: whitespace that could show is kept as one space, and optional closing tags and attribute quotes are left in place. Inline JavaScript with a syntax error is left as it is. Check the result in the HTML Viewer before you ship it.

Should I minify by hand on every change?

For one page, it's quick here. For a site you edit often, let your build tool do it (Vite, Astro and most generators do), and keep the readable version in your source.

Which minifier does it use?

html-minifier-terser, with Terser for inline JavaScript. It loads the first time you minify, then runs in your browser.

Is my HTML uploaded?

No. It's minified in your browser, and sent to Lobsite only if you press Publish this page.