HTML Minifier

Compress HTML by removing whitespace, comments and optional attributes.

or drag & drop a file here (.html, .htm, .xhtml, .shtml). Read in your browser, never uploaded.
Minified HTML
Paste, upload or load HTML code to minify...

Only comments and spaces that cannot change the result are removed; text inside strings, <pre> and <textarea> is kept exactly. Inline <style> and <script> code is minified too.

Website Management Tools

About the HTML Minifier

HTML Minify compresses your markup by removing extra spaces, line breaks and comments. There is an option to keep HTML comments if you need them. You can paste the code or load a file, and then copy or download the result.

Smaller HTML reaches the browser sooner, and this is the first file every visitor must download. Pages built by page builders can contain a lot of spacing, so the saving can be useful.

Text inside <pre> and <textarea> tags is left alone, because spacing matters there. On a website built with a CMS, minifying is usually done by a caching plugin, since HTML is generated afresh for each page.

How to use this tool

  1. 1Paste your HTML or load your file.
  2. 2Tick the option if you want to keep comments.
  3. 3Copy or download the minified code.
  4. 4Open the result in a browser and check that it looks correct.

Best-practice tips

  • Keep your readable version for future editing.
  • Check inline text after minifying, as a missing space between words can sometimes appear.
  • Use the HTML Formatter if you need to read minified code again.

Answers

HTML Minifier FAQs

It depends on how much spacing and how many comments it contains. Plain, tidy pages see smaller savings.

Related tools

Continue with these related website management tools.