HTML Minifier
Strip comments and collapse whitespace in HTML without touching pre, textarea, script or style blocks.
Minify HTML
Runs in your browser. The markup is not sent anywhere. Content of pre, textarea, script and style is never changed.
Minified HTML
What the HTML Minifier does
Templates are written for people, with indentation, blank lines and comments that explain why a block exists. None of that helps the browser, and every byte of it is downloaded before the page can be parsed. This minifier removes the parts a browser ignores: comments, the indentation between tags and repeated spaces inside text. On a typical hand-written page it saves 10 to 25 percent of the HTML, and more when the markup has been copied around a lot.
It is careful about the places where whitespace carries meaning. The contents of pre, textarea, script and style elements are left exactly as written, because a newline inside a pre block is visible and a comment inside a script may be code that a template engine needs. Conditional comments for old Internet Explorer (<!--[if IE]>) are kept too. Quote removal around simple attribute values is available but off by default, since some tools that read your HTML afterwards expect the quotes.
Paste the markup, tick the options you want, and compare the before and after sizes. Everything runs in your browser; the HTML is not sent to our server. The output is one line of markup, so keep the original in your repository and minify as part of the build or at publish time.
Step by step
- 01Paste the HTML of a page or a fragment into the input box.
- 02Leave "remove comments" and "collapse whitespace" on; turn on quote removal only when you know the result is read by browsers alone.
- 03Check the size row for the bytes saved and the percentage.
- 04Scan the output once; a page that relied on inline-block spacing between elements can shift by a few pixels.
- 05Copy the result or download it as an .html file.
Common questions
Minifying HTML only removes what the browser ignores. Markup that was already compact, or a page that is mostly inline script and style, has little to shed. The large wins on such pages come from gzip or brotli on the server, which you should enable regardless of minification.
Occasionally. Inline elements separated by a newline render with a space between them; the minifier keeps one space in that case, so text keeps its word breaks. A layout that used the whitespace between inline-block elements as a gap may lose it. Content in pre and textarea is never changed.
Minify the HTML the engine outputs, not the template. If you must minify templates, keep comments on so Blade, Twig or Handlebars directives written as comments survive. Conditional comments for Internet Explorer are preserved in every mode.
Only indirectly. Google renders minified and unminified HTML the same way. A smaller document loads faster, which feeds the Core Web Vitals and the page experience signal, so the benefit is speed rather than ranking by itself.
Keep checking
CSS Minifier
Minify a stylesheet in your browser: comments, whitespace and trailing semicolons out, strings and url() kept intact.
Free toolJavaScript Minifier
Remove comments and blank space from JavaScript while leaving strings, templates and regexes untouched.
Free toolSVG Optimizer
Clean an SVG in your browser: editor metadata, comments, empty groups and long decimals out, preview before and after.
Free toolImage Compressor
Compress and resize JPEG, PNG and WebP images in your browser; nothing is uploaded, download them one by one or all.
Want these fixes done for you?
Our team runs the audit, makes the changes and reports the result.