HTML Minifier

Compress HTML by stripping whitespace, comments, and redundant markup - free, no signup required.

Input HTML
Minified Output
Original: 0 B Minified: 0 B Saved: 0.0%

HTML Full Form

HTML stands for HyperText Markup Language - the standard markup language used to structure content on the web.

HTML source is written for humans to read and edit, so it's full of indentation, line breaks, and comments - all discarded by the browser at render time. Minifying HTML strips these away to produce a smaller document that, with the one exception described below, renders the same.

What this tool does

When minifying HTML pays off

The gain is biggest on pages that are written by hand and served often: a landing page, an email template, a static site without a build step, or an HTML snippet that a CMS stores and repeats on every page. Email is a good case, because some clients clip long messages, so trimming the markup can keep the whole email visible.

How to use it

  1. Paste your markup into Input HTML, or click Upload File to open an .html or .htm file. Load Sample fills in a short page that shows each rule in action.
  2. The minified version appears on the right as you type. Click Minify to run it again on demand.
  3. Read the stats line to see how many bytes you saved.
  4. Use Copy or Download (saved as minified.html), or Clear to start over.

How the minifier works

Before touching anything, the tool sets aside every <pre>, <textarea>, <script> and <style> block so its rules cannot damage them. It then deletes ordinary comments, removes whitespace that sits only between a closing > and the next <, and squeezes any remaining run of spaces, tabs and newlines down to a single space. Finally it puts the protected blocks back, with the CSS and JavaScript inside them minified by the same engines as our CSS Minifier and JS Minifier.

Example, and the one thing to watch

This input:

<p>Hello <b>big</b> <i>world</i></p>

becomes:

<p>Hello <b>big</b><i>world</i></p>

The space after "Hello" survives because it touches text, but the space between the two inline tags is removed, so the page now reads "Hello bigworld". The same happens between links in a menu or between inline-block buttons. Where a gap matters, put the space inside a tag, use &nbsp;, or create the gap with CSS margin.

Other limits

Privacy

Everything runs locally in your browser. Your HTML is never sent to our servers, not even for analytics.

Frequently Asked Questions

Will minifying break my HTML?
For 99% of documents, no. The minifier preserves pre, textarea, script, and style contents verbatim, keeps IE conditional comments, and keeps CDATA sections. Whitespace between inline tags is collapsed, so if you rely on it for spacing, use an nbsp or CSS margin.
Does it minify inline CSS and JavaScript?
Yes. Style blocks are passed through the CSS minifier and script blocks through the JS minifier before being re-embedded. Script tags with non-JS types (like application/json) are left untouched.
How much can I realistically save?
Hand-authored HTML shrinks by 20-40%; build-tool-generated HTML by 5-15%. After gzip the saving is smaller but still real - minification removes tokens the compressor still has to encode.
Is my HTML uploaded anywhere?
No. All minification runs inside your browser using client-side JavaScript. Nothing is sent to our servers, nothing is logged, and nothing is cached anywhere except your own browser tab.
Can I reverse the minification?
Click Beautify to pretty-print any HTML with indentation. Original comments are not recoverable, but document structure is fully restored and readable again.
Should I minify before or after templating?
After. Minifying template source before variable interpolation can mangle template syntax (Jinja, Liquid). Do interpolation first, then minify the rendered output as part of your build step.