← All blog posts

HTML Minifier for homeowners and DIYers

WhiteUI · A plain-English guide to the HTML Minifier

Homeowners and DIYers do not only build with timber and paint: many also run a small website for a trade, a rental, a club or a side business, and a page that loads slowly on a phone loses visitors before they read a word. The HTML Minifier trims the file behind the page so it arrives sooner, and it costs nothing and needs no software installed. The examples below use a shop page and a small page like the ones a home business actually has.

At a glance

Shop page: 19% smaller329 bytes removed1,415 bytes kept1,744 bytes in, 1,415 bytes out
A shop page with twenty products goes from 1,744 bytes to 1,415 bytes. The 329 bytes removed are the indentation and line breaks of twenty repeated blocks.

Example 1: a shop page with twenty products, 1,744 bytes to 1,415

A shop page is usually the same block repeated many times: a div, a product name, and a price, once per product. A page with twenty such blocks is 1,744 bytes as written, because every block carries its own indentation and line breaks. Minified it is 1,415 bytes, so 329 bytes are saved, or 19% smaller. The product names and the prices are copied exactly: Product 1 still costs Rs. 100 and Product 20 still costs Rs. 2000, because the tool never touches words or numbers, only the space around them.

Example 2: a small page, 291 bytes to 198

Most pages on a small site are not shop pages: a home page, an about page, or a contact page with a heading, a paragraph and a list. One such page, with a comment that reads page title in the head, is 291 bytes as written and 198 bytes minified, so 93 bytes are saved, or 32% smaller. The comment, which is 19 characters on its own, disappears. The heading still reads Hello world, with one space between the words, so the page looks exactly the same to a visitor.

How to do it for your own site

Open the tool and paste in the HTML of one page from your site. Read the three lines under the big percentage: the original size, the minified size, and the bytes saved. Then press Copy minified HTML or Download .html, and put the result where your page lives, keeping the original file somewhere safe. Do one page first and check it on your phone before doing the rest.

What to check before you publish

Check anything on the page where spaces matter. If the page has a pre block holding code or a price list in columns, the tool will collapse its spacing: a 61-byte pre block comes out as one line of 49 bytes, with its indentation gone. If the page has a comment sitting between two words, removing it joins the words, so Hello and world become Helloworld. And if a script on the page contains the characters <!-- inside a string, the tool will eat the string. A quick look at the page in a browser catches all three, and it takes less than a minute.

Keep the original file

The minified file is for the browser, not for you: it is one long line with no gaps, and editing it by hand is slow and easy to get wrong. Keep the original file with its line breaks and indentation, because that is the version a person can read and fix, and minify a fresh copy whenever the page changes. If you ever need to change a price or a phone number, change it in the original, minify again, and publish the new copy.

The common mistake

People minify their only copy of a page, lose the original, and then have to work from the one-line version when they want to change something. A navigation list that saved 15%, or 22 bytes out of 147, is not worth losing the readable original for. Save the original first, minify second, and publish the minified copy. That order takes ten seconds longer and saves an hour of frustration later.

Frequently asked questions

How much does a shop page save when minified?

A 20-product page goes from 1,744 bytes to 1,415 bytes, saving 329 bytes, or 19% smaller, with every product name and price unchanged.

Will minifying change how my page looks?

No. The words, prices and links stay exactly as they are; only comments, line breaks, indentation and doubled spaces are removed.

What should I check before publishing a minified page?

Open it in a browser and look at it, especially any pre block, price list in columns, or script, because the tool collapses whitespace everywhere.

Should I keep the original file?

Yes. Keep the original with its line breaks and indentation for editing, and minify a fresh copy whenever the page changes.

More guides on the HTML Minifier

Try it yourself

Try the HTML Minifier — free, in your browser.

Open the HTML Minifier