Minify HTML

Paste HTML to strip out comments and unneeded spaces so the file downloads faster. You see how much was saved, and nothing is uploaded.

How to use the HTML minifier

  1. Paste your HTML into the left box, or click Open File.
  2. The minified code appears on the right, with the size saving shown underneath.
  3. Click Copy or Download.

What minifying does

Code is written with spacing and comments so that people can read it. Browsers do not need any of that. Minifying removes it, which makes the file smaller, so pages load faster and use less data.

BeforeAfter
<div class="card">
  <h2>Title</h2>
  <p>Text</p>
</div>
<div class="card"><h2>Title</h2><p>Text</p></div>

What is removed

  • Comments
  • Line breaks and indentation between tags
  • Repeated spaces
  • Extra space in embedded <style> blocks

Is it safe?

The contents of <pre>, <textarea> and <script> are left as they are, and single spaces between words and inline tags such as links and bold text are kept, so the page displays the same. Keep your original file for editing and put the minified copy on your website.

Does minifying really help?

Typical savings are 15% to 30% for CSS and HTML and 30% to 60% for JavaScript. Smaller files mean quicker page loads, which helps visitors on phones and is one of the things search engines measure.

See also the CSS Minifier and the JavaScript Minifier.

Your data stays on your device

The conversion runs entirely in your web browser. Nothing you paste or open is sent to a server, so it is safe to use with customer lists, exports and other private data. There is no sign-up and no size limit beyond what your device can handle.

Frequently asked questions

How do I minify HTML?

Paste the code into the left box. The minified version appears on the right, ready to copy or download.

Will minified HTML still work?

Yes. Only characters the browser does not need are removed, so it behaves the same.

Can I turn minified code back?

You can add line breaks back with a formatter, but comments and original names are gone for good. Always keep your original file.

Is my code uploaded?

No. It is processed in your browser and never sent to a server.