This page removes optional characters from HTML: comments, whitespace between tags and repeated whitespace inside text. Three checkboxes control which of those changes are allowed, and the result area reports the before and after size so you can see whether the option set actually saved anything.
It scans the document into four kinds of part — tags, text, comments and raw blocks — and edits each kind with its own rule. That is not a full HTML parse, but it is enough to keep an attribute value such as title="two spaces" from being mistaken for text. It does not build a DOM tree, rename classes, or touch the JavaScript and CSS inside script and style.
What the three options do
Remove comments deletes ordinary HTML comments, including licence notices and analytics placeholders. Conditional comments are kept, because they are instructions to old versions of Internet Explorer rather than notes to a reader. If you still ship a conditional comment, this is the behaviour you want, and the stats count only the ordinary comments that went.
Remove whitespace between tags deletes whitespace that sits between two markup parts and contains nothing else. That space is usually insignificant, but not always: two inline-block elements separated by a newline render with a visible gap, and removing it closes that gap. The checklist warns about this, which is the honest position; the tool cannot know whether your layout depends on it.
Collapse text whitespace turns a run of spaces, tabs and newlines inside text into one space. This matches how HTML renders text by default, so a paragraph with three spaces between words looks the same before and after. It does not remove the single space between words, so the output stays readable.
A worked example
The page's 258-character sample has one comment, a newline and two-space indent between every tag, and a paragraph with single spaces. Minified with all three options on, it came back as 180 characters, 30.2% smaller, with one comment removed.
| Options | After | Saving |
|---|---|---|
| Comments, between tags, text | 180 | 30.2% |
| Between tags only | 210 | 18.6% |
| Text only | 222 | 14.0% |
| Comments only | 228 | 11.6% |
| None | 258 | 0% |
The all-options run removed the placeholder comment, the newlines and indentation between tags, and the repeated whitespace in text. The text inside strong kept its single spaces, and the paragraph stayed on one line, which is what the browser would render anyway.
The single-option rows are worth reading together. Between-tags alone saved the most, because the sample is indented on every line. Text alone collapsed each newline-and-indent run to one space rather than deleting it, so it kept 222 characters: the spaces still separate words and tags. Comments alone saved 30 characters, exactly the placeholder plus its delimiters.
Text collapsing is easier to see on messy input. A 56-character block with blank lines and runs of spaces inside a paragraph came back as 41 characters, 26.8% smaller, with the sentence intact. Turning on between-tags as well brought it to 39 characters by dropping the spaces left around the block elements.
Attributes, comments and raw blocks
Attribute values are never rewritten. A test element written as <p title="two spaces" data-json='{"a": "b"}'> came back byte for byte, still 52 characters. The same applies to a style attribute such as style="margin: 0 auto" and to an attribute containing >: the scanner follows quotes, so a greater-than sign inside a value does not end the tag.
An ordinary comment is removed entirely, including the delimiters. A conditional comment such as <!--[if IE]>.<![endif]--> is preserved as one block, and a test with one conditional and one normal comment removed only the normal one, reporting 44 characters from 59. That is a deliberate exception, not an oversight.
pre, textarea, script and style are protected. Their contents are copied exactly, because collapsing whitespace inside a pre would change the displayed code and collapsing it inside a textarea would change its default value. Someone else's JavaScript is also not this tool's business to reformat. A test with an indented script kept its comments, braces and spacing unchanged and only shortened the paragraph after it.
Because a raw block is one part, the between-tags option now works across its boundary. In the test, <pre> keep\n this </pre>\n<p> collapse this </p> lost the whitespace after the closing pre and kept both the preformatted text and the collapsed paragraph. An earlier version left a stray space there.
Protection also means those blocks are not minified. A large inline script or a style block keeps every space and comment, so the overall saving on a page with a lot of inline code will be smaller than the markup alone suggests. Minify the CSS and JavaScript separately if that matters.
What it will not do
It does not remove optional quotes around attribute values, does not shorten boolean attributes, and does not drop the optional closing tags that HTML allows. Those transformations save bytes but require a parser and a clear understanding of the document, and they can break naive string processing.
It does not touch inline event handlers, inline styles or the contents of script and style. It does not remove empty elements, merge adjacent text nodes or reorder attributes. And it does not validate: a malformed document goes in and a malformed document comes out, only shorter.
Text is edited only where it is genuinely text. A stray < in a sentence that never forms a tag is left as written rather than guessed at, and a comment inside a script block is left inside the script because the block is copied whole. Neither case is a loss: the output stays valid and nothing is silently moved.
The practical result is a modest reduction, typically 10-30% on hand-written markup with comments and indentation, and close to zero on markup that is already compact. That is not a failure. The page removes only characters that are safe to remove without understanding the document, and it reports zero when there is nothing to remove.
Checking before you deploy
Compare the rendered page, not only the character count. The two risks are the inline-block gap and a comment that a script reads from the DOM. A comment used as a template or a marker will be gone, and the script that looks for it will fail silently.
Keep the original file. Minification is one-way in practice, and comments that documented a decision are not recoverable from the output. The HTML beautifier can make the result readable again, but it cannot bring the comments back. For a structural comparison, paste both versions into the code diff checker.
If you need a real build-step minifier, use one that parses HTML and can also process the linked CSS and JavaScript. This page is for a quick reduction on a snippet, an email template or a one-off page where adding a build step is not worth it.