← All text tools

HTML Minifier

Remove comments and extra whitespace from HTML, optionally minify inline CSS and JavaScript, and see the bytes saved.

  • Free
  • No sign-up
  • Works on any device

About HTML Minifier

Shrink an HTML page by removing what browsers do not need. Comments are dropped (conditional comments are kept), runs of whitespace become one space, and in aggressive mode the space next to block elements disappears. Pre, textarea, script and style content is never touched by those rules. Optional steps minify inline CSS in style tags and style attributes, remove comments and spare spacing from scripts while keeping line breaks for safe semicolon handling, compact JSON-LD data, and drop quotes around attribute values where HTML allows. The result shows the byte count before and after in UTF-8.

How to use HTML Minifier

  1. Paste the HTML and choose how aggressively whitespace is collapsed.
  2. Tick whether to remove comments, minify inline CSS and JavaScript, or remove attribute quotes.
  3. Compare the sizes, test the minified page in a browser, then copy or download it.

Why use this tool?

Also known as

Frequently asked questions

Will minifying change how my page looks?

It should not. The safe mode only collapses whitespace runs, and the aggressive mode trims space next to block elements, which browsers ignore anyway. Always check the result before you publish.

Why does the JavaScript keep its line breaks?

JavaScript can end a statement at a line break when the semicolon is missing, so removing every break could change what the code does. Keeping them avoids that risk.

How much smaller will my file get?

Typically a few percent for compact pages and more for pages full of indentation and comments. After gzip or Brotli on the server the difference is smaller still.

Is HTML Minifier free?

Yes. HTML Minifier on Toolipedia is free to use, with no sign-up and no watermark.

Is it safe to use?

Yes. Everything is worked out in your browser, and nothing you enter is sent to our server.

Does it work on my phone?

Yes. It works in any modern browser on Android and iPhone, as well as on tablets and computers. There's nothing to install.

Do I need an account?

No. Just open the page and use the tool. There's no sign-up and no email needed.

Can I put HTML Minifier on my own website?

Yes. Use the Embed on your site button under the tool to copy a short piece of code and paste it into your page. It is free, needs no account, and the tool keeps working inside your page.

Related tools