What this tool does
Readable HTML becomes the smallest HTML that renders identically.
<div>
<p> Hello </p>
</div>
<div><p> Hello </p></div>
Runs of whitespace become one space, the whitespace between block elements goes, and comments go — except the conditional ones, which are instructions to an old browser rather than notes to a reader.
The space between two inline elements is content
<span>a</span> <span>b</span>
<span>a</span> <span>b</span>
Nothing to strip there: that space is rendered, and removing it turns “a b” into “ab”. It used to be removed, which made the page different rather than smaller — a real defect, found while writing this page and fixed. Around a block element the same space renders as nothing, so it goes:
<div>a</div> <div>b</div>
<div>a</div><div>b</div>
Attribute values are not layout
<input value="a b">
<input value="a b">
The two spaces stay. They used to be collapsed into one, because the whitespace pass ran straight through the attributes — and the value a form submits, the text of a title, the content of an alt are data, not indentation. Quoted values are set aside before the collapse and put back untouched.
What it never enters
<pre>and<textarea>. Displayed or submitted exactly as written.<script>and<style>. Their content is JavaScript and CSS; the minifiers for those are separate tools on this site, and running them is your decision, not a side effect of this one.- Conditional comments.
<!--[if IE]>…<![endif]-->is read by a browser, so it stays.
One limit worth knowing: a protected region ends at its closing tag, found by pattern. A literal </script> inside a JavaScript string therefore ends it too early. Catching that case properly takes a full HTML parser, which is a different tool from a whitespace minifier.
Private by design
Everything runs locally in your browser with JavaScript. Your data is never uploaded, which makes the tool safe for sensitive content, and it keeps working offline.