Skip to content

HTML Minifier

Strip comments and extra whitespace from HTML.

Everything runs in your browser. Nothing is uploaded.

More Developer Tools

All tools

How to use the HTML minifier

Three steps, all in your browser.

  1. 1

    Paste your input

    Type or paste your code or data. Press Sample to try an example.

  2. 2

    Pick the style

    Choose indentation or options. The result updates as you type.

  3. 3

    Copy the result

    Copy the output in one click. Nothing is saved or sent anywhere.

HTML Minifier: what to know

The HTML minifier removes comments and the whitespace between tags where it's safe. It tokenizes the document rather than using regular expressions, so attribute values are never changed, and the content of <pre> and <textarea> elements, where whitespace is visible, is left exactly as it was. Inline <style> and <script> blocks are kept as they are unless you choose to minify them too.

HTML is whitespace-sensitive between inline elements: two links separated by a line break render with a space between them. That's why whitespace next to block elements such as <div> and <p> is removed, while whitespace between inline elements is collapsed to a single space, so the page should look the same before and after.

Conditional comments for old Internet Explorer versions (<!--[if IE]>) and comments that start with <!--! are kept, since some pages still rely on them. Everything else between <!-- and --> is removed.

Popular uses

  • Shrinking static HTML pages without a build step
  • Compacting HTML email templates
  • Minifying HTML snippets stored in a database or CMS
  • Checking how much of a page's size is whitespace

Tips for the best result

  • Minify the output, not the template you edit: keep a readable source.
  • Compare the page visually after minifying, especially around inline elements and buttons placed side by side.
  • Use the HTML formatter to reverse the process when you need to read minified markup.

Read how JustYourDev works and our privacy details. Code, data and files you use here are processed in your browser and are never sent to our server.

Frequently asked questions

Mostly. Whitespace inside <pre> and <textarea> is meaningful and is kept. Between inline elements a single space can matter (two links next to each other), which is why runs of whitespace are collapsed to one space rather than removed everywhere.

It depends on how the page was written; heavily indented templates and pages with many comments shrink the most. The tool shows the exact before and after size. Server compression (gzip or Brotli) reduces the gap further.

No. Every tool runs in your browser, so your code, tokens, keys and files are processed on your device and are not sent to our server or stored. Reloading or closing the page clears them.

Yes. Every tool is free with no sign-up and no limits on use. Clearly labeled ads keep it that way.

Yes. The tools work in any modern browser on phones, tablets and computers, though large files and long code are easier to handle on a computer.