Skip to content
Sealpaste

Delete all recent work?

This removes the 0 items saved in this browser. Your settings stay.

Stop saving recent work?

New work won't be saved in this browser. The 0 items already saved can stay or go.

HTML Minifier

HTML

Paste HTML, or

CtrlV paste · Ctrl↵ run now

Minified HTML
Ready
Ln 1, Col 1
Runs in your browser. Nothing you paste is uploaded unless you share it.

Minify HTML: comments and extra space go, inline CSS and JS are minified, <pre> and attribute values stay as written

Make a page smaller without changing how it shows: comments and the space a browser ignores go, and the CSS and JavaScript inside it are minified too.

How to use it

  1. Paste HTML, or open an .html file.
  2. The result shows at once; the status bar says how many characters it has and how much smaller it is.
  3. Under Options, keep comments or line breaks, drop optional end tags, default attributes and quotes, write booleans bare, sort classes, keep template tags, or set a maximum line length.
  4. Copy it or download minified.html. Switch Mode to Format to make it readable again.

Examples

Comments and spaces go, words keep one space

Input
<ul class="nav">
  <!-- main links -->
  <li><a href="/">Home</a></li>
  <li><a  href="/docs" >Docs</a></li>
</ul>
<p>Read   the <b>docs</b>  first.</p>
Result
<ul class="nav"><li><a href="/">Home</a></li><li><a href="/docs">Docs</a></li></ul><p>Read the <b>docs</b> first.</p>

<pre> stays, <style> is minified

Input
<pre>
  two  spaces
    stay
</pre>
<style>
  .note { color: #555555; }
</style>
Result
<pre>
  two  spaces
    stay
</pre><style>.note{color:#555}</style>

What goes, what stays

  • Comments go, except conditional ones (<!--[if IE]>) that old browsers still read.
  • Runs of space become one space, and none at all next to block elements like <div>, <p> and <li>, where it doesn’t show.
  • Between inline elements like <a> and <b> one space stays, because it shows as a gap between words.
  • <pre>, <textarea> and attribute values stay as written; scripts of other types (JSON-LD, templates) too.
  • Inline <style> is minified by csso and inline <script> by Terser. Code they can’t read stays as written, with a note.

Going further, under Options

Dropping optional end tags and attribute quotes saves a little more, but a page edited later can break in ways that are hard to see, so they are off until you pick them. End tags go only where HTML’s optional-tag rules let the next tag close them (</li> before <li> or </ul>, </td> before <td> or </tr>, </option> before <option>), and quotes only where the value has no space, quote, =, <, > or backtick.

Keep line breaks leaves one line break where the source had one, for readable diffs; Max line breaks long lines only at a space or next to a block tag, where a break shows nothing. Keep template tags leaves {{ }}, {% %}, {# #} and <% %> exactly as written.

Questions

Will the minified page look different?
It shouldn’t: only space a browser ignores is removed. If a page relies on CSS like white-space: pre on an element other than <pre>, check that part, since its space is collapsed.
Can it read a template with {{ }} or <% %>?
Text between tags is left alone apart from spaces, so most template tags pass through. Turn on Keep template tags under Options to leave {{ }}, {% %}, {# #} and <% %> exactly as written, spaces inside and tags holding them included.
Is my HTML uploaded?
No. Everything runs in your browser, so your page stays on your device. Nothing you paste is uploaded unless you share a result, which is locked with your password first.

Related tools