Minify HTML

Paste HTML and press Minify to remove whitespace between tags. Content inside pre, textarea, script and style is left intact, and the markup is never executed or rendered. Use it on email templates and CMS exports that contain customer data. Minifying runs in this tab; nothing is uploaded.

Input
Output
Minified in this tab16 lines307 BNever executed

Runs in this tab · nothing is uploaded · Verify in 10 seconds →

What this does

Minify HTML removes insignificant whitespace between tags so email templates and CMS exports become smaller to store or send. Content inside pre, textarea, script and style is copied as written. The markup is never assigned to innerHTML or loaded in an iframe, so scripts cannot run.

Only inter-tag whitespace is removed. A typical email template with two-space indent shrinks 10 to 30 percent; already-compact React output barely changes. The first line of a nested <pre> may be indented with its parent; the inner text is not collapsed.

When it goes wrong

An unclosed comment or an unclosed tag shows a friendly error with line and column. Fix that first. If a downstream renderer then looks different, it was depending on whitespace between inline elements, which HTML treats as a single space in most contexts but not inside pre.

When to use this

Minify before shipping an email template, embedding a snippet in a CMS field, or comparing two exports after you have inspected them formatted.

This page is a focused view of theHTML Formatter & Beautifier, which has the full set of options.

Frequently asked questions

Does this upload my HTML?

No. Minifying runs in this tab. Email templates and admin pages never leave the device.

How do I minify HTML?

Paste it and press Minify. The sample below is already compacted.

Does it change pre, script or style?

The inner text is left intact. Only the opening tag may be indented with its parent.

Does the minifier execute my HTML?

No. There is no innerHTML and no iframe. Scripts do not run and images do not load.

Can I pretty-print it back?

Yes. Press Format, or open the full HTML Formatter for indent options.

Is this the same as an HTML beautifier?

Beautify (Format) adds indentation. Minify removes it. They are opposite actions on the same tokenizer.