Helper-KitCode Tools

HTML Minifier & Beautifier

Minify HTML, including inline CSS and JavaScript, or beautify messy HTML into clean, indented markup. Shows the size saved.

HTML
Try an example:
Minified HTML

More:CSS MinifierJavaScript MinifierHTML EntitiesXML Formatter

Minifying removes comments and only the whitespace a browser would never show. Text in <pre> and <textarea> stays exactly as written, the single space between inline elements like <b> and <i> is kept, and IE conditional comments and comments starting with <!--! are preserved. Inline CSS and JavaScript are minified with CSSO and Terser. Beautifying uses Prettier. Everything runs in your browser.

About This Tool

Paste HTML, open a .html file or drop one in. Minify mode collapses whitespace, removes comments and tidies tags, while keeping the content of <pre> and <textarea> exactly as written. CSS inside <style> tags is minified with CSSO and JavaScript inside <script> tags with Terser. JSON-LD structured data is compacted too. Special comments are kept: Internet Explorer conditional comments and comments that start with <!--! are left in place. If tags look unclosed or do not match, a warning lists them so you can check your markup. Beautify mode uses Prettier to indent HTML neatly, including the CSS and JavaScript inside it. Everything runs in your browser; your code is never uploaded.

Common Use Cases

  • Reducing the size of HTML pages and email templates
  • Making minified HTML from a website readable
  • Finding unclosed or mismatched tags
  • Minifying a page together with its inline CSS and JavaScript
  • Formatting HTML before sharing or editing it

Frequently Asked Questions

Will minifying change how my page looks?

It should not. Spaces between words and inline elements are kept as single spaces, and the content of <pre> and <textarea> is never changed. Spaces next to block elements, such as <div> and <p>, are removed because browsers ignore them.

Does it minify inline CSS and JavaScript?

Yes. <style> blocks are minified with CSSO and <script> blocks with Terser. If an inline block cannot be minified, it is left as it was and you are told.

Which comments are kept?

Internet Explorer conditional comments and comments that start with <!--! are kept. Other comments are removed when "Remove comments" is on.

Does it check my HTML?

It warns about tags that are opened but never closed, or closed without being opened. Elements that do not need a closing tag, such as <br> and <li>, are not reported.

Was this tool helpful?

More in this category