About HTML Minifier
Paste a page or a template and get a compact copy back, with the bytes saved shown underneath. Comments are removed, runs of spaces and line breaks become a single space, and whitespace between block elements, which never shows on the page, is dropped.
The content of <pre> and <textarea> is left exactly as written, attributes and their quotes are untouched, and old Internet Explorer conditional comments survive. Turn on inline CSS and JavaScript minifying to shrink <style> and <script> blocks as well.
How it works
- Your HTML is parsed with Prettier’s HTML parser, which follows the same rules for implied and optional tags as browsers do, and printed back with the indentation and line width you chose.
- Inline elements such as links and emphasis stay on the line of the text around them, so formatting does not add visible spaces to your page; text inside <pre> and <textarea> is kept as it was.
- In Minify mode a separate pass removes comments and the whitespace that cannot show on the page, and can also minify inline CSS with csso and inline JavaScript with Terser.
- The work runs in a background worker, so a large page never freezes the tab.
Questions
Can minifying change how my page looks?
It keeps a space wherever one could be visible, such as between two links or a label and an input. The one case it cannot see is an element that your CSS sets to white-space: pre; give that element a <pre> tag, or keep its file out of the minifier.
What if a script or style block has an error?
That block is left exactly as written and a note under the result gives its line, so the rest of the page is still minified. JSON and template blocks in <script> tags are never changed.
Why is minifying JavaScript off by default?
It needs Terser, a further download of about 300 KB, and it renames local variables. Most pages gain little from it compared with minifying their separate script files.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.