⌕
Developer · free online tool

HTML Minifier.

Minify HTML while preserving inline scripts.

Your workspace◈ Processed on your device
Your result
Your result will appear here.

A little context.

Removes comments and collapses safe whitespace. Preserves preformatted text and does not minify embedded JavaScript or CSS. Output is shown as text and is never executed. Test the result before deploying it.

Reducing markup with a reviewable result

Minify a copy of your HTML and compare its rendered behavior in your own test environment before replacing production files. This tool presents the output as text, so pasted markup is not run on this page.

Interpreting the result and avoiding mistakes

Comments can carry application-specific meaning and whitespace can matter in inline layouts. Embedded JavaScript and CSS are not minified. Keep source files readable and minify deployment copies; never treat minification as an HTML sanitizer.

A reproducible workspace example

These are the starting values in the form above. The result below is calculated from these values when the page is built, using the same processing engine as the tool.

HTML
<main>
  <h1>Hello, world!</h1>
  <p>Less friction. More done.</p>
</main>

Calculated output

<main> <h1>Hello, world!</h1> <p>Less friction. More done.</p> </main>

Quick reference

<div> <span>Hello</span> </div> → compact HTML

How to use this tool

  1. Enter html in the workspace above.
  2. Select Run tool to process your input. Invalid values produce a message next to the form.
  3. Copy the result or download it as a file. Reset example restores the original input.

Keep a good thing going.

A few related tools for your next step.