Map Extract
Free tool

HTML minifier and beautifier

Paste HTML to strip comments and surplus whitespace, with an option to tighten inline styles and scripts too, and see how many bytes you saved. Switch to Beautify to turn a single crammed line of markup into indented, readable code.

Runs in your browser. Nothing you enter is uploaded.

Minifying or tidying markup

  1. Paste the HTML

    A full page, an email template or a fragment. The presets load a page fragment, a snippet with comments and a simple email table.

  2. Pick the mode

    Minify removes comments and collapses whitespace between and inside tags. Beautify re-indents the markup with 2 or 4 spaces.

  3. Set the options

    Tick Also minify inline style and script to compress CSS and JavaScript inside the page. Tick Keep comments if you want ordinary comments left in; Outlook conditional comments are kept either way.

  4. Read the saving

    Under the output you see the size before and after in bytes and the percentage saved.

  5. Copy or download

    Copy the result or download it as an HTML file.

Example: a promotion block for an email

A heating engineer's marketing email (fictional) has an offer block pasted from a page builder, full of indentation, a leftover comment and an inline style. Minified with the inline option ticked, the comment goes, runs of spaces collapse to one, and the CSS inside the style tag is tightened as well.

Spaces that separate words, such as the one between Book a and free, are kept, so the text reads exactly as before.

Input
<!-- hero -->
<div class="offer">
   <h2>Spring   offer</h2>
   <p>Book a  <strong>free</strong> survey</p>
   <style> .offer { color : #1f3a2c ; } </style>
</div>
Result
<div class="offer"><h2>Spring offer</h2><p>Book a <strong>free</strong> survey</p><style>.offer{color:#1f3a2c}</style></div>

Where size actually matters

For an ordinary web page served with compression, minifying HTML saves less than people expect, because gzip already squeezes out repeated whitespace. It matters more in places where the raw size counts: HTML email, where some mail apps truncate long messages and show a link to view the rest; snippets pasted into a CMS field with a character limit; and embedded widgets you hand to a client.

Beautify is the more useful half for many people. Page source copied from a browser, an exported template or an HTML email you received often arrives as one long line. Indented, it is much easier to find the part you want to change.

Before you replace the original

  • Keep the unminified version; edit that one in future and minify again.
  • Check that text inside pre and textarea tags still looks right, since spacing there is meaningful.
  • If ordinary comments carry notes for the next person who edits the template, tick Keep comments.
  • Send a test email or load the page and look at it before publishing.

Questions people ask

Does minifying HTML improve SEO?

Only indirectly. Smaller pages can load slightly faster, and speed is one of many things search engines consider, but the effect of HTML minification on a typical small business site is small, especially when the server already compresses pages. Image sizes, scripts and hosting usually make a far bigger difference.

Will minifying break my email template?

It should not change how the email looks, and Outlook conditional comments are left in place. Email clients are fussy, though, and a few templates rely on whitespace in unusual ways. Always send yourself a test across the mail apps your customers use before sending to a list.

What does Beautify do with inline styles and scripts?

Beautify concentrates on the HTML structure: it puts tags on their own lines and indents nested elements. Content inside style and script blocks is carried across rather than reformatted, so for those parts the CSS and JavaScript tools on this site do a better job.

Is my HTML sent anywhere?

No. Minifying and beautifying run in your browser as you change the text or options. Nothing is uploaded, which matters if the markup contains unpublished offers or client details.

Where your data goes

All processing happens in your browser. The HTML you paste is not sent to Map Extract or any other server.

Checked against the tool on

Top