webdev_html_minifier
Minify HTML by stripping comments, collapsing whitespace, and optionally removing empty elements, redundant quotes, and optional closing tags. Also minifies inline CSS and JS.
Instructions
HTML Minifier. Minify HTML by stripping comments, collapsing whitespace, and optionally removing empty elements, redundant quotes, and optional closing tags, plus minifying inline style CSS and script JS. Pass the markup as the html parameter; every transform is an independent boolean toggle. Use webdev_css_minifier or webdev_js_minifier to compress standalone stylesheets/scripts, web_dev_html_to_markdown to convert HTML to Markdown, and webdev_javascript_beautifier to expand rather than compress. Regex/heuristic minifier, not an HTML parser, so unusual or malformed markup may need review; conditional comments are preserved. Runs locally via a Node bridge: read-only, non-destructive, contacts no external service, rate-limited (60 requests/minute for anonymous callers). Returns the minified HTML plus original/minified byte sizes, byte savings, and compression ratio.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| html | Yes | HTML markup to minify. Must be a non-empty string. | |
| removeComments | No | Strip HTML comments. Conditional comments are always preserved. | |
| removeWhitespace | No | Collapse runs of whitespace, trim, and remove whitespace between tags. | |
| removeEmptyElements | No | Remove elements whose content is empty or whitespace-only. | |
| removeQuotes | No | Drop quotes around attribute values that are safe to unquote (alphanumerics, hyphen, underscore). | |
| collapseInlineTagWhitespace | No | Collapse whitespace around inline tags (span, a, strong, b, i, em, small, code, etc.). | |
| preserveLineBreaks | No | Accepted for compatibility; reported back in options but does not currently alter output. | |
| removeOptionalTags | No | Remove optional closing tags such as the paragraph close before a block-container end and the list-item close before a list end. | |
| minifyInlineCSS | No | Minify CSS inside style attributes (strip comments and collapse whitespace). | |
| minifyInlineJS | No | Minify JavaScript inside script blocks (strip comments and collapse whitespace). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| original | No | The original HTML, echoed back. | |
| minified | No | The minified HTML output. | |
| originalSize | No | Original length in characters. | |
| minifiedSize | No | Minified length in characters. | |
| savings | No | originalSize minus minifiedSize (bytes removed). | |
| compressionRatio | No | Percent size reduction, rounded to 2 decimals; 0 when input is empty. | |
| options | No | The fully-resolved option set actually applied (every toggle with its effective boolean). |