Free tools, no sign-up — everything runs in your browser.
ToolHub 1000Free online tools

HTML Minifier Guide: Between-Tag Whitespace Explained

Learn why whitespace between tags is safe to remove while whitespace inside text is not.

What is the HTML Minifier?

This tool removes HTML comments and the whitespace that sits between a closing angle bracket and the next opening one, then trims the result. Whitespace inside text is left alone, so words in a paragraph are not joined together by accident. It does not touch attribute values or inline scripts and styles beyond the between-tag whitespace, so it is a light cleanup rather than a full production minifier.

How to use it

  1. Paste your HTML into the box.
  2. Click Minify HTML.
  3. Copy the compact markup.

Worked example

For the sample, the comment disappears and the markup becomes <div class="box"><p> Hello world </p></div>, with the spaces inside the paragraph text preserved.

Will minifying HTML change how my page looks?

Not usually, because browsers ignore most between-tag whitespace. Text spacing and preformatted content are the exceptions, so check those areas.

Frequently asked questions

Does it remove spaces inside text?

No. Only whitespace between tags is collapsed, so the words inside a paragraph keep their spacing.

Does it remove comments everywhere?

It removes standard HTML comments. Comments inside scripts or styles are left to their own rules and are not specially handled.

Try the HTML Minifier free · All guides