Free · Fast · Privacy-first

Minify HTML Tags Online

HTML tag minification goes beyond whitespace removal.

Collapses whitespace between tags

🔒

Removes optional closing tags safely

Preserves all required tag attributes

Free and instant

Cost
Free forever
Sign-up
Not required
Processing
In your browser
Privacy
Files stay local
FreeNo signupWhite-label

Add this HTML Minify to your website

Drop the HTML Minify into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.

  • Files stay 100% in the visitor's browser
  • Responsive — adapts to any container width
  • Free forever, no API key needed

Embed code

<iframe
  src="https://www.fixtools.io/html/html-minify?embed=1"
  width="100%"
  height="780"
  frameborder="0"
  style="border:0;border-radius:16px;max-width:900px;"
  title="HTML Minify by FixTools"
  loading="lazy"
  allow="clipboard-write"
></iframe>

Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.

Tag-Level HTML Minification: Optional Tags, Boolean Attributes, and Safe Shortcuts

Most developers think of HTML minification as whitespace removal, but tag-level optimisation goes further and produces additional savings on top. The HTML5 specification explicitly permits omission of certain closing tags in defined contexts. The closing tags for li, dt, dd, p (when followed by specific sibling elements), colgroup, thead, tbody, tfoot, tr, th, td, option, and optgroup are all optional under specific conditions defined precisely in the spec. A fully optimised HTML minifier removes all of these where the specification permits, shaving additional bytes beyond what whitespace removal alone achieves. For pages with extensive list markup, table structures, or select menus with many options, tag-level optimisation can reduce file size by an additional 3 to 8 percent beyond whitespace removal.

Boolean attribute simplification is another meaningful tag-level optimisation. In HTML5, boolean attributes have a defined shorthand form that is equivalent to the verbose form. The attribute disabled="disabled" is completely equivalent to simply disabled. The attribute checked="true" is equivalent to checked. The attribute required="required" is equivalent to required. A minifier that handles boolean attributes applies the shorthand form to every instance across the document. For forms-heavy pages with multiple required, disabled, readonly, selected, and checked attributes, this can save hundreds of bytes across all form elements on a complex page with many inputs, selects, and checkboxes.

When minifying complex tag structures, always verify the output by running it through the HTML Formatter to expand it and visually confirm the nesting hierarchy is intact. Pay particular attention to table elements, where optional tag removal is most aggressive, and to list elements in navigation and content sections. If the formatter reveals unexpected nesting after expansion, paste the specific problematic section back into the minifier in isolation to identify the edge case.

Comment preservation is the one tag-level decision that genuinely depends on the audience for the page. Standard HTML comments contribute no value to a production response and should be removed without hesitation, yet conditional comments using the legacy IE pragma syntax are still functionally meaningful for sites whose analytics show non-trivial traffic from Internet Explorer 8 or 9. Most teams in 2026 see zero such traffic and can strip conditional comments along with everything else. Some enterprise audiences, government portals, and certain regional markets still record measurable IE usage and continue to need conditional comments preserved. The pragmatic approach is to check the browser breakdown in your analytics platform before configuring the minifier: if old IE versions account for under one tenth of one percent of sessions, strip every comment without exception; if the number is higher, preserve conditional comment blocks while still removing standard developer comments throughout the rest of the document.

How to use this tool

💡

Paste your HTML and minify. The output has the most compact tag structure possible while remaining valid HTML.

How It Works

Step-by-step guide to minify html tags online:

  1. 1

    Paste your HTML

    Paste HTML with verbose tag structure into the input panel. This includes HTML with full boolean attribute syntax such as required="required", optional closing tags on list items and table cells, and all standard whitespace indentation from a code editor.

  2. 2

    Minify

    Click Minify to produce compact tag-level HTML. The tool removes whitespace between tags, applies optional tag omission where the HTML5 specification permits, and shortens boolean attributes to their single-word shorthand form.

  3. 3

    Verify output

    Check the output for correctness, paying particular attention to sections with optional closing tags such as lists, tables, and select elements. Paste the output into the HTML Formatter to expand it and visually confirm the nesting structure matches the original.

  4. 4

    Copy and use

    Copy the compact HTML for use in production. The output is valid HTML5 that all modern browsers parse identically to the original verbose source.

Real-world examples

Common situations where this approach makes a real difference:

Minifying a component library HTML output

Component libraries generate verbose HTML with many optional closing tags and full-form boolean attributes throughout form inputs, buttons, and interactive elements. Minifying a single component template from 4.2KB to 3.1KB saves 1.1KB per template. When that template is used in a component library rendered across 80 pages, the total saving across the site is 88KB of HTML that users no longer download, compounding across every page view.

Compacting form-heavy HTML with many boolean attributes

A registration form with 20 input fields where each uses required="required" saves approximately 18 bytes per field from boolean attribute shortening. Across 20 fields that is 360 bytes from this one optimisation alone. Add disabled="disabled" on conditional fields, selected="selected" on default options, and checked="checked" on default checkboxes, and the total saving from boolean attribute shortening on a single complex form can reach 600 to 800 bytes.

When to use this guide

Use this when you want to understand what the minifier does to specific HTML tags, or when you need to minify a fragment of HTML with complex tag structures.

Pro tips

Get better results with these expert suggestions:

1

Audit optional tag removal with a diff

After minifying and then re-formatting the output, run a diff between the formatted output and the original source to see exactly which optional closing tags were removed. This comparison is educational for understanding which HTML5 optional tag rules are being applied and gives you confidence that the minifier is applying only the removals that the specification explicitly permits, not making conservative guesses about what might be optional.

2

Boolean shorthand improves readability too

Beyond file size reduction, the boolean attribute shorthand form, writing disabled instead of disabled="disabled", is actually easier to read at a glance because the attribute name alone communicates its meaning without a redundant value. Some development teams adopt this convention in source HTML even without minification as a code style preference, and many HTML linters can be configured to enforce it in source code.

3

Watch for XHTML legacy patterns

If your HTML was originally written as XHTML with all tags explicitly closed and boolean attributes written as name="name", the minifier will apply more aggressive simplification than you might expect. The output will be valid HTML5 but may look unfamiliar if you are accustomed to XHTML conventions. Verify the output renders correctly in your target browsers and confirm your JavaScript does not parse the HTML string with an XML parser, which requires all tags to be explicitly closed.

4

Minify HTML strings passed to innerHTML

When setting element content via JavaScript using innerHTML or insertAdjacentHTML, the HTML string is parsed by the browser's standard HTML parser, which is fully whitespace-tolerant. Minifying any HTML strings stored in JavaScript variables or constants before bundling reduces the overall JavaScript file size. For component-heavy applications where dozens of template strings are bundled, this can collectively reduce the JavaScript bundle by several kilobytes.

5

Optional closing tags can be removed safely

HTML5 allows omission of closing tags for certain elements (li, dt, dd, p in certain contexts). Minifiers take advantage of this where the spec permits.

6

Boolean attribute simplification

Minifiers can shorten boolean attributes: disabled="disabled" becomes just disabled. This is valid HTML5 and saves a few bytes per attribute.

7

Verify tag structure after minifying

For complex HTML with many nested elements, run the minified output through the formatter and validator to confirm the tag structure is correct after minification.

FAQ

Frequently asked questions

Yes, within the limits defined by the HTML5 specification. The spec explicitly lists which closing tags are optional and under what conditions they can be omitted. The browser parser is required to infer these tags correctly when they are absent, so the resulting DOM is identical whether the optional tags are present or not. A well-implemented minifier removes only the tags that the specification defines as optional, never those that are required.
Removing optional tags eliminates specific closing tags that the HTML5 specification designates as inferrable by the browser parser in particular contexts. The document structure is unchanged because the parser infers the missing tags. Stripping tags means removing HTML element nodes from the document entirely, which changes the content and structure of the page. Minification removes optional tags; it never strips actual elements from the document. Stripping elements would be destructive and is not what any minifier does.
The HTML5 specification defines closing tags as optional for the following elements in specific contexts: html and body (when content allows), head (when not followed by a comment), li (when followed by another li or at the end of its parent), dt (when followed by dt or dd), dd (when followed by dd, dt, or at the end of the parent), p (when followed by block elements or at the end of the parent), rt, rp, optgroup, option, colgroup (when not followed by a space or comment), caption, thead, tbody, tfoot, tr, td, and th.
No. Screen readers, voice navigation tools, and all assistive technologies interact with the browser's parsed Document Object Model, not with the raw HTML source markup. The browser parser infers all optional closing tags and constructs a complete, correctly structured DOM regardless of whether the tags are present in the source. Because the DOM is identical with or without optional closing tags, the accessibility tree exposed to assistive technology is also identical, and accessibility is completely unaffected.
No. Boolean attribute shorthand has been valid HTML since HTML4 and is supported in every browser including Internet Explorer 6 and above, all versions of Firefox, Chrome, Safari, and Edge. The verbose form such as disabled="disabled" was only strictly required in XHTML, which follows XML parsing rules that require all attribute values to be quoted and non-empty. In HTML, which uses the browser's forgiving parser, the single-word form has always been the canonical representation.
Custom elements using the Web Components specification, such as my-component or x-modal, are treated as unknown elements by the HTML parser and by the minifier. Their opening and closing tags are preserved without modification because the specification does not define optional tag rules for custom elements. Whitespace between custom element instances is removed in the same way as whitespace between any block elements, but no closing tag removal or boolean attribute shortening is applied to custom element attributes.
Paste the minified output into the HTML Formatter to expand it back to a readable indented form, then compare this expanded output visually against the original source. Verify that all list items, table rows, and table cells appear at the correct nesting levels. Additionally, run both the original source HTML and the minified output through the W3C HTML Validator and confirm both pass validation. If the minified version shows different structural errors or warnings than the original, identify the specific element that changed and determine whether the minifier applied an optional tag removal incorrectly.
React validates the string passed to dangerouslySetInnerHTML as HTML, and the framework relies on the browser parser to construct the resulting subtree. If the minified string omits an optional closing tag that the parser handles correctly but a downstream framework reconciler does not expect, hydration mismatches can occur and the rendered subtree diverges from React expectations. The fix is to keep optional closing tags intact in any HTML destined for dangerouslySetInnerHTML and to apply only whitespace and comment minification on those strings. Configure your build to use a less aggressive minification profile for the specific JavaScript files that contain dangerouslySetInnerHTML payloads, leaving the rest of your HTML to receive full tag-level optimisation.
Boolean attribute shortening can surprise scripts that read attribute values as strings. The shorthand form disabled returns the empty string when accessed through getAttribute, whereas the verbose form disabled="disabled" returns the literal string disabled. Code that compares attribute values strictly against the string disabled will see false after minification, even though the input is still disabled from the user perspective. The reliable pattern is to use the boolean DOM property, for example element.disabled, which returns true or false regardless of the attribute representation. Refactor any getAttribute comparisons to property reads and the script becomes robust against any future minification configuration.
Void elements are elements that cannot contain content and therefore have no closing tag. The HTML5 specification defines the full void list as area, base, br, col, embed, hr, img, input, link, meta, source, track, and wbr. In HTML5 these elements are written without any closing tag and without a trailing self-closing slash, so the canonical minified form for an image is img with attributes followed by a closing angle bracket and nothing more. The XHTML-style self-closing slash, which writes br as br with a trailing slash and a closing bracket, is allowed by the HTML5 parser for compatibility but adds two bytes per occurrence and conveys no semantic information. A minifier optimising for the smallest valid HTML5 output strips the trailing slash from every void element. The self-closing slash debate splits opinions among developers familiar with XML, JSX, or older XHTML codebases, who often prefer the slash form as a visual cue that the element is void. Some teams retain the slash purely as a code style preference even in HTML5, and a configurable minifier exposes this as a setting so different projects can match their authoring conventions. XHTML compatibility is the one technical reason to keep the slash: documents served with an XML MIME type such as application/xhtml+xml are parsed as XML and require every element to be explicitly closed, which means void elements must use the self-closing form to remain valid. Documents served as text/html, which is the default for almost every modern web application, are parsed by the HTML parser that ignores the optional slash regardless of whether it is present. If your project genuinely serves XHTML through the XML MIME type, configure the minifier to preserve self-closing slashes on void elements. If you serve standard text/html responses, which is the case for the vast majority of sites in 2026, the slash can be removed safely and the resulting HTML5 is shorter, fully spec-compliant, and parsed identically by every browser.

Related guides

More use-case guides for the same tool:

Ready to get started?

Open the full HTML Minify — free, no account needed, works on any device.

Open HTML Minify →

Free · No account needed · Works on any device