Developer Tools

HTML Minifier

Live

Reduce HTML size by removing comments and collapsing whitespace between tags while preserving preformatted content.

About HTML Minifier

Reduce HTML size by removing comments and collapsing whitespace between tags while preserving preformatted content. Enter html input, remove ordinary html comments, collapse text whitespace in a purpose-built workspace that keeps related controls together and makes units explicit. Comments outside conditional markup are removed, ordinary text whitespace is collapsed, and spacing between tags is reduced while pre, textarea, script, and style blocks are protected. The result panel reports minified html, original size in bytes, minified size in bytes, size reduction with copy-ready values and supporting context. Whitespace can be meaningful in inline content, templates, email HTML, and custom elements. Review the rendered result before deployment. Processing stays in your browser and the entered values are not sent to UtilityPages.

Set up HTML Minifier

Workspace

Source workbench

Edit the source fields below and inspect the rendered output alongside your work.

Complete the fields to prepare a result.

Paste HTML markup to minify.

Turn remove ordinary html comments on or off.

Turn collapse text whitespace on or off.

HTML Minifier results

Enter the values above, then minify html to see the result.

HTML Minifier method

Comments outside conditional markup are removed, ordinary text whitespace is collapsed, and spacing between tags is reduced while pre, textarea, script, and style blocks are protected.

How it works

Comments outside conditional markup are removed, ordinary text whitespace is collapsed, and spacing between tags is reduced while pre, textarea, script, and style blocks are protected. Whitespace can be meaningful in inline content, templates, email HTML, and custom elements. Review the rendered result before deployment.

Examples

HTML Minifier example

Example input
{
    "html": "<main>\n  <!-- Intro -->\n  <h1>UtilityPages</h1>\n  <p>Fast browser tools.</p>\n</main>",
    "remove_comments": true,
    "collapse_text_whitespace": true
}
Expected result
{
    "minified_html": "<main><h1>UtilityPages</h1><p>Fast browser tools.</p></main>",
    "original_bytes": 84,
    "minified_bytes": 60,
    "savings_percent": 28.57
}

Privacy

This tool does not store your inputs or results on UtilityPages.org.

Frequently asked questions

How does the HTML Minifier work?

Comments outside conditional markup are removed, ordinary text whitespace is collapsed, and spacing between tags is reduced while pre, textarea, script, and style blocks are protected.

What information should I enter in the HTML Minifier?

Enter html input, remove ordinary html comments, collapse text whitespace. Use values from the same scenario and keep measurement units consistent with the labels shown.

What results does the HTML Minifier provide?

The result workspace reports minified html, original size in bytes, minified size in bytes, size reduction. Supporting values are included so the primary result can be checked and interpreted.

How exact is the HTML Minifier?

Whitespace can be meaningful in inline content, templates, email HTML, and custom elements. Review the rendered result before deployment.