{{ summaryTitle }}
{{ summaryValue }}

{{ summaryLine }}

{{ badge.label }} {{ badge.value }}
{{ summaryAnnouncement }}
HTML minification inputs
Paste, drop, or browse one source. Minification updates locally as you edit.
{{ sourceActionHint }}
Choose the spacing boundary before reusing the generated markup.
Review licensing and legacy-email requirements before removing every comment.
Keep is neutral and preserves the baseline HTML output policy.
Preserve values is neutral; collapse only for an HTML shorthand handoff.
{{ params.collapse_boolean_attributes ? 'Collapse values' : 'Preserve values' }}
Keeping the source slash is neutral for the baseline artifact.
{{ params.keep_closing_slash ? 'Keep source slash' : 'Remove HTML void slash' }}
{{ exportAnnouncement }}
{{ computation.values.minified_html }}
CheckStatusEvidenceNext stepCopy
{{ row.check }}{{ row.status }}{{ row.evidence }}{{ row.next_step }}
{{ exportAnnouncement }}
{{ exportAnnouncement }}

The chart renderer is unavailable. Exact byte values remain in the compression ledger.

MetricValueMeaningCopy
{{ row.metric }}{{ row.value }}{{ row.detail }}
{{ exportAnnouncement }}

Readable HTML contains indentation, line breaks, comments, and generously spaced attributes that help people maintain it. A browser often needs fewer of those bytes to build the same document. Minification removes characters judged unnecessary for delivery while trying to preserve the markup's meaning and rendered text.

Whitespace is not equally disposable everywhere. A newline between two block elements is usually formatting, but a single space between inline elements may be the only thing separating two visible words. Contents inside <script>, <style>, <pre>, and <textarea> also follow special rules. Comments can carry license notices, preservation directives, or conditional markup used by older email clients.

HTML areas and their minification risk
AreaTypical reductionMain risk
Tag syntaxCollapse redundant spacing around names, attributes, and equals signs.Changing quoted or templated values.
Text between tagsReduce repeated whitespace.Joining visible inline words.
CommentsRemove delivery notes.Losing legal, preservation, or conditional comments.
Raw and preformatted textProtect contents from outer cleanup.Changing code, styles, or significant spacing.
Boolean attributesShorten values such as disabled="disabled" to disabled.Applying shorthand to an attribute that is not truly boolean.

A smaller byte count is useful for transfer and storage, but it does not prove semantic equivalence. Template delimiters, embedded languages, legacy email markup, malformed tags, and application-specific preprocessing can all change what is safe. Keep maintainable source under version control and treat minified HTML as a generated delivery artifact.

How to Use This Tool:

Start with the least aggressive policy that meets the size goal, then render-test the generated markup in its real environment.

  1. Paste, drop, or browse the HTML source. The accepted source limit is 2 MiB.
  2. Choose a Minification profile. Delivery compact removes safe block and void-element boundary spacing, while Aggressive preview removes every inter-tag space.
  3. Set Comment handling. Preserve important comments unless licensing and legacy-email requirements have already been checked.
  4. Choose whether inline style contents stay unchanged or have comments and redundant CSS whitespace compacted.
  5. Enable boolean-attribute shorthand or remove void-element closing slashes only when the target uses HTML syntax and accepts those forms.
  6. Review Safety checks and Byte savings. Repair malformed tags and render-check any aggressive-spacing or comment warning before copying the output.

Interpreting Results:

Bytes saved and Reduction compare the minified output with the normalized input. A low reduction can still be correct when the source was already compact. The output can also be larger after normalization; that condition is reported instead of being hidden by a negative savings value.

Zero safety findings means no built-in warning rule fired. It does not certify valid HTML, accessibility, template compatibility, or identical rendering. Pay particular attention to aggressive spacing, removed comments, compacted style blocks, and possible malformed tags, then test the generated markup with the same parser and rendering path used in production.

Technical Details:

HTML minification here is a deterministic text transformation rather than a full browser parse and reserialization. That preserves control over the output but limits what can be proven about malformed markup or embedded template syntax.

Transformation Core

The stages run in a fixed order so protected contents are restored only after the surrounding markup has been compacted.

  1. Convert carriage-return line endings to line feeds and trim outer whitespace.
  2. Temporarily isolate complete <script>, <style>, <pre>, and <textarea> blocks. Style contents are changed only when style-whitespace compaction is selected.
  3. Apply the comment policy outside those protected blocks. “Keep important” retains conditional, license, copyright, and preservation comments.
  4. Separate tags from text while respecting quoted attribute values. An unterminated tag-like segment remains text and raises a warning.
  5. Collapse repeated text whitespace and compact spacing inside tags. Optional passes shorten recognized boolean attributes and remove the slash from recognized HTML void elements.
  6. Compact whitespace between tag boundaries according to the profile, normalize the doctype outside Conservative mode, and restore protected blocks.
HTML minification profile behavior
ProfileInter-tag boundary ruleDoctype handlingReview need
ConservativeRemove boundary whitespace when either adjacent tag is block-level or void.Preserve the original doctype wording with compact spacing.Render-check normal markup and templates.
Delivery compactUses the same block and void boundary rule.Normalize to <!doctype html>.Render-check normal markup and templates.
Aggressive previewRemove whitespace between every adjacent pair of tags.Normalize to <!doctype html>.Inspect inline word boundaries before reuse.

Formula Core

Byte metrics use UTF-8 length after input normalization. Savings never falls below zero, and the displayed percentage retains the full computed value until presentation.

Bsaved=max(0,BinputBoutput) reduction=BsavedBinput×100%

The compression ratio is output bytes divided by input bytes. Character counts and byte counts may differ because non-ASCII characters can occupy two to four UTF-8 bytes.

Exact shorthand rules

Boolean shortening applies only to a fixed set of standard boolean attributes and only when the existing value is empty or matches the attribute name without regard to case. Values such as disabled="true" are not shortened. Closing slashes are removed only from recognized HTML void tags such as <br />, <img />, and <input />.

Limitations and Privacy:

Source and output stay in the current browser tab. The transformation is not a standards validator, accessibility checker, template compiler, JavaScript minifier, or complete CSS optimizer.

  • Style compaction removes CSS comments and compresses common punctuation spacing; validate complex or generated CSS separately.
  • Raw blocks are found by matching complete start and end tags, so malformed or unusual embedded markup may not be isolated as intended.
  • Sources above 750,000 bytes raise a performance warning, and sources above 2 MiB are rejected.
  • Removing all comments also removes conditional and legal comments; recovery requires the original source.

Worked Examples:

Inline words separated by tags

Markup such as <span>Hello</span> <strong>world</strong> needs the inter-tag space to render “Hello world.” Delivery compact retains a space when both adjacent tags are inline. Aggressive preview removes it, so the rendered result may become “Helloworld” and the safety warning calls for a visual check.

Important comments and boolean shorthand

With “Keep important comments,” an ordinary delivery note is removed while a comment containing @license remains. Enabling boolean shorthand turns disabled="disabled" into disabled; it leaves a noncanonical value unchanged for review.

References: