Current status
{{ summaryMetric }}
{{ summaryLine }}
{{ profileBadge }} {{ formatCount(result.savedBytes) }} B saved {{ formatCount(result.outputBytes) }} B output {{ result.commentsRemoved }} comment(s) removed Browser-only {{ result.warnings.length }} warning(s)
HTML minifier inputs
Paste the markup to compact; the minified output and byte ledger update as you type.
{{ sourceActionHint }}
{{ fileStatus }}
Choose how hard the browser-side pass may collapse whitespace around tags and text nodes.
Keep important comments when testing legacy or licensed markup; remove all only for trusted source.
Keep raw text blocks untouched, or compact only inline style block whitespace.
Leave off for exact attribute review; turn on for a more compact trusted handoff.
{{ collapse_boolean_attributes ? 'Collapse' : 'Preserve values' }}
Keep source-style slashes by default; remove them only for HTML5 delivery output.
{{ keep_closing_slash ? 'Keep slash' : 'Remove slash' }}
{{ result.output }}
Metric Value Detail Copy
{{ row.metric }} {{ row.value }} {{ row.detail }}
Check Status Detail Copy
{{ row.check }} {{ row.status }} {{ row.detail }}

        
Customize
Advanced
:

Introduction

HTML usually carries two jobs at once. It has to describe a document for the browser, and it has to remain readable enough for people to review, debug, and maintain. Indentation, line breaks, spacing around attributes, and explanatory comments help the second job. Most of those characters are not needed by the parser when the page, fragment, template, or email markup is ready to be delivered.

Minification is the review pass that separates authoring convenience from delivery meaning. The safest reductions remove bytes that are clearly formatting, such as repeated spaces inside tags or blank lines between block elements. Riskier reductions touch areas where characters may still matter: the only space between inline words, a license comment, a conditional comment used by legacy email clients, or text inside an element that preserves spacing.

Common HTML minification decisions
Markup Area Usually Safe to Reduce Needs Review
Tag formatting Extra spaces around tag names and attributes. Unquoted attributes and unusual templating markers.
Inter-tag whitespace Line breaks between block or void elements. Spaces between inline elements that render as text.
Comments Temporary review notes and ordinary delivery comments. License, copyright, preserve, and conditional comments.
Raw-text blocks Surrounding document whitespace outside the block. Script, style, preformatted, and textarea contents.
Authoring HTML passing through a review step before becoming smaller delivery HTML

Some HTML vocabulary matters before a compact result can be trusted. Void elements such as img, input, meta, and link have start tags but no HTML end tags. Boolean attributes such as disabled, checked, and required are true when present, so their value text can sometimes be shortened. Raw-text elements such as script and style, plus preformatted content and text areas, need different handling from ordinary prose.

A smaller HTML string is not proof that the document is valid, accessible, or visually unchanged. Minification is best used as a focused size and cleanup check before a rendered test, template review, or email-client preview. The useful question is not only how many bytes were removed, but whether the removed characters were only formatting.

How to Use This Tool:

Start with the markup and the safety profile, then use the ledger and warnings to decide whether the compact copy is ready.

  1. Paste markup into HTML source, drop a local file onto the textarea, or choose Browse HTML. HTML, HTM, SVG, and TXT files are read in the browser, and selected files over 2 MB are rejected before processing.
  2. Choose Minification profile. Delivery compact is the default for normal delivery markup, Conservative keeps more inline spacing, and Aggressive preview removes every inter-tag space for source that will be rendered and checked afterward.
    If the summary or Safety Checks warns about aggressive spacing, inspect inline text before copying the compact result.
  3. Set Comment handling. The default keeps important comments while removing ordinary comments. Use Preserve all comments during review, and use Remove all comments only after license, copyright, preserve, and conditional comments have been checked.
  4. Open Advanced when the destination needs a narrower policy. Keep Inline asset handling on raw-text protection for mixed markup, enable style whitespace compaction only when style blocks are safe to compact, and turn on boolean-attribute or void-slash changes only for HTML5-style output.
  5. Read the summary and Compression Ledger. The ready state should show input bytes, output bytes, bytes saved, comments removed or preserved, protected blocks, style blocks compacted, attribute compaction, and tag scan counts that match the source you meant to process.
  6. Check Safety Checks before copying. Fix malformed-tag warnings, reconsider all-comment removal, and treat a larger-output warning as a sign that protected blocks or already compact markup are dominating the result.
    Pasted HTML over 750,000 bytes can still run, but the warning means browser-side processing may feel slower on low-memory devices.
  7. Use Minified HTML as the handoff text after the warnings are acceptable. Use the HTML Byte Savings Chart or JSON only when you need an audit record of the size change.

Interpreting Results:

The headline percentage compares normalized input bytes with minified output bytes. It is a size signal, not a validity signal. A good result is smaller, keeps raw-text blocks protected where needed, preserves important comments under the selected policy, and reports no warning that would change how the markup should be reviewed.

HTML minifier result signals and review actions
Result Signal What It Means What to Check Next
Saved bytes and percent smaller The output uses fewer UTF-8 bytes than the normalized source. Review the actual markup if savings came from comments, inline spacing, or shorthand attributes.
Comments removed or preserved The selected comment policy was applied to ordinary HTML comments. Keep important comments when licensing, copyright, preserve markers, or legacy conditional behavior matters.
Protected blocks Script, style, preformatted, and textarea regions were separated from general whitespace cleanup. Style-block whitespace changes happen only when that advanced option is selected.
Malformed-tag warning An unfinished or suspicious tag-like segment was treated as text. Fix the source before treating the byte savings as useful.
Output larger than input The normalized source was already compact or protected text dominated the document. Use the original source or change settings instead of forcing a smaller number.

The common mistake is copying the smaller string because the percentage looks good. Copy it only after the warnings and the fragile parts of the markup agree with the way the HTML will be rendered.

Technical Details:

HTML minification depends on the difference between syntax whitespace and text whitespace. Extra spacing inside a start tag can often be reduced to the single spaces needed between attributes. Whitespace between two block elements is commonly just formatting. Whitespace between inline text runs can render as a visible word separator, so removing it can change the page even when every tag remains valid.

The raw-text boundary is the other major constraint. JavaScript, CSS, preformatted text, and textarea content can use spaces, line breaks, and comment-like characters as meaningful content. A cautious HTML minification pass protects those regions before applying broader tag, comment, and inter-tag whitespace rules, then restores the protected text into the compacted document.

Formula Core

Size reporting uses UTF-8 byte counts after line endings are normalized and outer whitespace is trimmed. Saved bytes are floored at zero so already compact input does not produce a negative saved-byte display.

Bsaved = max(0,Binput-Boutput) Psaved = BsavedBinput×100 Ratio = BoutputBinput

A 482 byte sample that becomes 385 bytes saves 97 bytes. The displayed reduction is 97 divided by 482, or 20.1 percent after rounding.

Transformation Core

HTML minification transformation stages
Stage Rule Review Boundary
Normalize input Line endings become consistent and outer whitespace is trimmed before byte counting. Comparisons stay repeatable across pasted text from different operating systems.
Protect raw text Script, style, preformatted, and textarea regions are isolated from general HTML cleanup. Style blocks are compacted only when the inline asset option allows it.
Apply comment policy Comments can be preserved, all removed, or filtered so important comments remain. Important-comment detection is a safety aid, not a legal review.
Compact tags and text Repeated tag spacing and safe text whitespace runs are reduced according to the profile. Aggressive preview accepts more inline-spacing risk.
Apply shorthand Boolean attributes can be collapsed and slashes on HTML void tags can be removed. Use shorthand only when the destination expects HTML5-style serialization.

Spacing and Syntax Boundaries

HTML minifier syntax boundaries
Boundary Technical Concern Safer Reading
Block and void element edges Whitespace is often layout in the source text, not visible document text. Delivery compact can remove many of these spaces safely.
Inline text edges Removing the only separator between inline elements can join words. Use Conservative for text-heavy fragments, then render-check the result.
Boolean attributes disabled="disabled" and disabled both express presence in HTML. Collapse values only when reviewers and downstream systems expect the shorter form.
Void tag slash A trailing slash on an HTML void element is unnecessary and has no self-closing effect. Keep the slash during mixed HTML/SVG review, remove it for compact HTML5 output.
Foreign or template-like markup SVG, MathML-like islands, and server templates can carry syntax expectations outside ordinary HTML. Prefer a conservative profile and rendered or template-level validation.

Advanced Tips:

  • Use Conservative when the fragment contains inline text split across tags, because the safer profile keeps more boundary spacing.
  • Keep Raw text blocks protected unless the source is mostly ordinary HTML and inline style whitespace has already been reviewed.
  • Compare the Comments row with the original source before using Remove all comments; conditional and license comments can matter outside the visible document.
  • Use boolean-attribute collapse and void-slash removal together only when you want compact HTML5 serialization rather than a source-style review copy.
  • Use the HTML Byte Savings Chart for a quick audit of input, output, and saved bytes, but rely on rendered HTML for visual confidence.

Limitations and Privacy:

The minification run happens in the browser, and pasted HTML is not sent to a server. Local files are read as text in the browser and must be under 2 MB. Very large pasted source can still trigger a performance warning because the work runs on the current device.

  • Minification is not full HTML validation. A malformed-tag warning catches common unfinished tag patterns only.
  • Rendered layout, accessibility, browser compatibility, and email-client behavior still need separate checks.
  • Template syntax, SVG, MathML-like content, and legacy email markup can require rules that a browser-side token pass cannot prove.
  • Removing all comments can discard license, copyright, preserve, or conditional comments that should remain in delivered markup.

Worked Examples:

These examples show how to read the result as a review decision, not just as a smaller byte count.

Launch-page sample

The built-in sample has a style block, one ordinary comment, and a disabled button. With Delivery compact, Keep important comments, raw-text protection, and source-style void slashes kept, the ledger reports 482 input bytes, 385 output bytes, 97 bytes saved, and a 20.1% reduction. The result is ready to inspect because the ordinary comment is removed, the style block is protected, and the warning list stays quiet.

Legacy email fragment

A table snippet that contains an <!--[if mso]> conditional comment should use Conservative and the default important-comment policy. A smaller output is useful only if Safety Checks leaves the conditional comment preserved and no inline words are joined in the email preview.

Broken paste during review

A fragment ending with an unfinished tag such as <p class="lead" can still produce text output, but Safety Checks reports a malformed-tag warning. Fix the source first, then rerun the minification so the byte comparison reflects real markup rather than a broken paste.

FAQ:

Can minified HTML change visible text?

Yes. The main risk is removing the only visible space between inline elements. Use Conservative for text-heavy fragments and render-check any result produced with Aggressive preview.

Does pasted HTML leave my browser?

No. The minification run is browser-local, and the JSON audit excludes the raw pasted HTML. Local files are read as text in the browser when they are under the 2 MB file limit.

Why did the output get larger?

The tool warns when output bytes exceed input bytes. This usually means the source was already compact, protected raw-text blocks dominated the document, or the selected safety settings left little formatting to remove.

Should I remove all comments?

Only after reviewing the source. The default keeps important comments because license, copyright, preserve, and conditional comments can matter even when they do not render visibly.

Does this replace a build-system HTML minifier?

No. Use it for browser-side inspection, snippets, and size audits. Automated deployment rewrites should still use parser-backed tooling, tests, and rendered QA in the build process.

Glossary:

Minification
Removing safe authoring characters so HTML uses fewer delivery bytes while keeping the intended document meaning.
Raw-text block
A script, style, preformatted, or textarea region whose spacing may matter and should not be treated like ordinary HTML formatting.
Void element
An HTML element with only a start tag and no HTML end tag, such as img, input, or meta.
Boolean attribute
An HTML attribute that is true when present, such as disabled, checked, or required.
Conditional comment
A legacy comment pattern often found in older compatibility or email markup.
UTF-8 byte count
The encoded byte size used for input, output, saved-byte, and percentage calculations.

References: