HTML minifier
Paste HTML to get a lighter copy. By default it keeps one space between tags so the text layout does not change.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Enter html code and remove whitespace between tags completely.
- The result appears straight away and updates as you edit.
- Copy the result, or copy a link that keeps the same values to share it.
How it is calculated
HTML comments are removed except conditional ones, every whitespace run in text and inside tags becomes one space, and pre, textarea, script and style content is copied as is. Saving = (original - minified) / original × 100.
Example
Inputs: Remove whitespace between tags completely = no. Result: Minified HTML: <div class="card"> <h2> Title </h2> <p>Some text here.</p> </div>; Original size: 93 bytes; Minified size: 65 bytes.
<!-- header -->
<div class="card">
<h2> Title </h2>
<p>Some text here.</p>
</div><div class="card"> <h2> Title </h2> <p>Some text here.</p> </div>
Limits and caveats
- Inline JavaScript and CSS are copied as is, not minified.
- If CSS such as white-space: pre applies to an element other than pre, its spacing may change.
- Removing all whitespace between tags can join words in neighbouring inline elements such as <b> and <i>.
Questions about this tool
Why is one space kept between tags by default?
Space between two inline elements shows on screen, and one space renders the same as several.
Are Internet Explorer conditional comments removed?
No. Comments starting with <!--[if are kept as they are.
Do attribute values change?
No. Anything inside quotes stays exactly as written; only the spaces between attributes are collapsed.
