HTML Minifier
{{ summaryMetric }}
{{ summaryLine }}
{{ profileBadge }} {{ formatCount(result.savedBytes) }} B saved {{ formatCount(result.outputBytes) }} B output {{ result.commentsRemoved }} comment(s) removed Disabled review {{ 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 minification reduces markup size by removing characters that help humans read source but are not usually needed for browser parsing. Indentation, repeated spaces, line breaks, and ordinary comments can make a document pleasant to edit, yet they add bytes to every delivery copy.

The hard part is knowing which characters are safe to remove. Whitespace between block elements is usually harmless, but whitespace between inline content can create a visible word gap. Comments may be throwaway notes, license notices, legacy conditional comments, or review breadcrumbs. Raw-text areas such as scripts, styles, preformatted text, and textareas need extra care because their spacing can be part of the payload.

HTML source moving through raw-text protection, compaction, and review checks

A good minified result is not only shorter. It should preserve meaningful text spacing, leave sensitive source regions intact, and give enough evidence to spot risky settings before the output is copied into a release path.

Minification is also not a syntax repair step. A smaller document can still contain invalid nesting, missing closing brackets, unsupported legacy patterns, or application-specific assumptions that only a parser-backed build step or browser test can catch.

Technical Details:

HTML parsing separates markup into tags, attributes, comments, and text. Text nodes and raw-text content deserve special caution because collapsing whitespace can change what a user sees or what a script, style block, preformatted block, or textarea receives.

Void elements such as img, input, meta, and link do not have end tags in HTML. A trailing slash on a void start tag is optional syntax, not a closing operation. Boolean attributes such as disabled, checked, and required are true by their presence, so a repeated value can be shortened only when that change matches HTML boolean-attribute rules.

Transformation Core

The minification pass follows a fixed text transformation for the same source and options. It does not rebuild the document with a full HTML parser.

HTML minification transformation stages
Stage Rule Review Point
Normalize source Line endings are normalized and outer whitespace is trimmed before byte counts are taken. Byte savings compare against this normalized input, not the untouched editor text.
Protect raw-text zones script, style, pre, and textarea regions are isolated before outer cleanup. Style blocks are compacted only when the inline asset setting asks for style whitespace cleanup.
Handle comments The comment policy removes regular comments, preserves all comments, or preserves important comments such as license, preserve, copyright, and conditional comments. Use the safer default when comments may carry legal or legacy-browser meaning.
Compact tags and text Repeated spaces inside tags are reduced, text whitespace runs become one space, and inter-tag spaces are removed according to the selected spacing profile. Aggressive spacing needs visual review because it removes every inter-tag space.
Apply optional HTML shorthand Boolean attributes can be collapsed, and trailing slashes can be removed from HTML void start tags when those advanced switches are enabled. Keep exact attribute output when reviewing mixed HTML, SVG-like, or XHTML-like source.

Spacing And Comment Rules

HTML minifier spacing and comment policy behavior
Setting Behavior Best Use
Conservative inline-safe Keeps more inline spacing while still cleaning tag spacing and repeated text whitespace. First review of markup with inline text, icon spans, or tight phrasing.
Delivery compact Removes whitespace at block and void boundaries while preserving one space where inline boundaries need it. Default delivery review for normal page and component markup.
Aggressive preview Removes every inter-tag space after the token pass. Short experiments only, followed by a visual check of inline text.
Remove regular comments, keep important Removes ordinary comments and keeps conditional, license, preserve, copyright, and licence comments. Default review when legal notices or legacy conditions may appear.
Remove all comments Deletes every HTML comment found outside protected raw-text zones. Trusted source where comments have already been cleared for removal.

The byte calculation is simple: input bytes minus output bytes gives saved bytes, floored at zero for the summary. If the output becomes larger than the input, the warning list explains that the source may already be compact or that protected blocks dominate the document.

Everyday Use & Decision Guide:

Start with Delivery compact and Remove regular comments, keep important. That pairing usually gives a useful first pass for page fragments, landing sections, copied snippets, and SVG-like text while keeping license and conditional comments visible for review.

Use Conservative inline-safe when the source contains many inline elements, text nodes broken across lines, icon spans, or hand-tuned spacing. Use Aggressive preview only when you can compare the rendered result afterward, because removing every inter-tag space can join visible words or inline elements.

  • Paste source into HTML source, browse for a supported local text file, drop a file onto the editor, or load the sample.
  • Keep Inline asset handling at the default when scripts, style blocks, preformatted text, or textareas should remain untouched.
  • Choose Compact inline style block whitespace only when embedded CSS spacing cleanup is wanted but script, pre, and textarea content must stay protected.
  • Leave Boolean attributes on preserve-values mode when exact source review matters.
  • Keep Void tag slash on when the source intentionally uses XHTML-like void tags, and remove it only for HTML5 delivery output.

The selected file path reads text into the page workflow, and pasted source is minified in the browser. The local-processing note is about the HTML source path; page assets may still be loaded by the surrounding site.

The result is a review artifact, not a release guarantee. Check Safety Checks before copying the minified output, especially when warnings mention aggressive spacing, remove-all comments, possible malformed tags, large source, or output that grew instead of shrank.

Step-by-Step Guide:

Use the editor, profile settings, warning alert, and result tabs as checkpoints from source text to reviewed compact markup.

  1. Paste markup into HTML source, choose Browse HTML, drop an HTML, HTM, SVG, or TXT file onto the editor, or use Load sample to see the default output.
  2. Choose Minification profile. Start with Delivery compact, move down to Conservative inline-safe for careful inline text review, or use Aggressive preview only for inspected output.
  3. Choose Comment handling. Keep the default for most delivery checks, use Preserve all comments for audits, or use Remove all comments only after license and conditional notes are cleared.
  4. Open Advanced when the default raw-text, boolean-attribute, or void-slash behavior needs to match a project rule.
  5. Read the summary badges. A normal run reports the percent smaller, saved bytes or output bytes, removed comment count, disabled review badge, and any warning count.
  6. Open Minified HTML to inspect the exact output before copying or downloading it.
  7. Open Compression Ledger for input bytes, output bytes, saved bytes, comment counts, protected blocks, style-block compaction, and attribute compaction.
  8. Open Safety Checks if a warning appears or the output will be handed to a build step. Fix malformed tags or risky spacing before using the output.
  9. Use HTML Byte Savings Chart to compare input bytes, output bytes, and saved bytes when a visual summary helps a handoff.
  10. Use JSON when another reviewer needs the selected options, metrics, warnings, ledgers, and output in one structured payload.

If a selected file is over 2 MB, choose a smaller file or paste a focused fragment. If the large-source warning appears above 750,000 bytes, expect slower browser performance on low-memory devices.

Interpreting Results:

The summary percentage is useful only after the warning list is clear. A high byte reduction does not prove that spacing, comments, and raw-text areas are still acceptable. Inspect the minified HTML first, then use the ledger and checks to explain what changed.

HTML minifier result interpretation cues
Output Cue Meaning Follow-up
Bytes saved Input bytes minus output bytes after normalization. Compare with Output bytes when source was already compact.
Comments Counts removed and preserved comments under the selected policy. Switch to preserve-all or the safer default when a removed comment may carry legal or legacy meaning.
Protected blocks Counts script, style, pre, and textarea regions isolated before cleanup. Check this row when a source has embedded code or preformatted text.
Tag scan Reports clean tag scanning or possible malformed tags treated as text. Repair unterminated tags before trusting the compact output.
Spacing profile Shows whether spacing is ready or needs review. Render or browser-test aggressive output before handoff.

Use the JSON payload as evidence of the run settings and metrics. Do not treat it as proof that the HTML parses the same way in every target browser or build pipeline.

Worked Examples:

Landing Page Fragment

A section with a headline, paragraph, button, one ordinary delivery comment, and readable indentation works well with Delivery compact. The ordinary comment is removed, repeated whitespace collapses, and Compression Ledger should show positive Bytes saved plus the number of scanned tags.

License Comment Kept

A source block containing <!-- @license MIT --> should keep that comment under Remove regular comments, keep important. The Comments row should show the preserved count, while ordinary notes such as <!-- remove during build --> are removed.

Inline Spacing Review

A snippet with adjacent inline elements such as <span>Save</span> <strong>now</strong> needs a spacing check. Delivery compact keeps one inter-tag space where the boundary is not treated as block or void. Aggressive preview can remove that space, so Safety Checks marks the spacing profile for review.

Protected Text Area

A form containing a textarea with line breaks should leave that inner content alone while surrounding tags are compacted. The ledger's Protected blocks row should increase, and the minified output should still show the textarea content with its original spacing.

Malformed Tag Troubleshooting

A pasted fragment ending with <div class="card" has an opening bracket without a closing angle bracket. The warning list reports a possible malformed tag, and Tag scan marks the issue. Add the missing > before copying the minified result.

FAQ:

Does minification change what the page displays?

It should not when spacing and comment settings fit the source, but visible changes are possible around inline text. Review Minified HTML and use Safety Checks before relying on aggressive spacing.

Are selected files uploaded for minification?

Selected HTML, HTM, SVG, and TXT files are read as text into the browser workflow, and the source-processing path does not send pasted markup to a backend for minification.

Why did the output become larger?

The warning appears when output bytes exceed input bytes. That can happen when source was already compact or protected raw-text regions dominate the document, so compare Input bytes, Output bytes, and Protected blocks.

What comments are kept by the default policy?

The default removes regular comments while keeping important comments that look like conditional comments or include license, licence, preserve, or copyright wording.

Why does a malformed tag warning matter?

A possible malformed tag is treated as text during scanning. Fix the unclosed or malformed tag before using the output, then check that Tag scan returns to a clean status.

Should this replace a build minifier?

Use it for review, handoff, and quick inspection. For automated deployment rewrites, run a parser-backed build minifier and browser tests before replacing production markup.

Glossary:

Boolean attribute
An HTML attribute whose presence means true, such as disabled or checked.
Byte savings
The difference between normalized input bytes and output bytes after minification.
Comment policy
The selected rule for removing, preserving, or partly preserving HTML comments.
Inter-tag whitespace
Whitespace between adjacent tags, where removal can be safe at block boundaries but risky around inline text.
Raw-text zone
A protected region such as script, style, preformatted text, or textarea content.
Void element
An HTML element such as img or input that has no end tag in HTML syntax.

References: