toolo.dev

HTML Minifier

Minify HTML online without breaking the layout: pre, textarea, script and style are left intact and word spacing is kept. Optional inline CSS and JS minify.

After you click or type in the editor, the Tab key indents. Press Escape, then Tab, to move to the next field.

About the HTML Minifier

Paste a page or a fragment into the HTML minifier and it strips comments, indentation and line breaks without changing how anything looks. Text in <pre> and <textarea> stays exactly as written, the code inside <script> and <style> isn't minified unless you ask, and wherever a space would show between two words, one space is kept.

Turn on Minify Inline CSS and JS to shrink the code inside <style> and <script> too, or switch to Format to indent a minified page with Prettier, which also catches tags that don't match. Everything runs in your browser.

  1. Paste a full page, an email template or a CMS snippet into Input HTML. Load Example fills in a page with a comment, a <pre> block, a <style> block and a script.
  2. With Minify selected, choose what to remove. Remove Comments, Remove Empty Attrs and Collapse Whitespace start switched on. Minify Inline CSS and JS starts off.
  3. Minified HTML shows the result. Original Size, Minified Size and Savings refresh about half a second after your last change, so you can toggle an option and compare.
  4. Switch to Format to get indented markup in Formatted HTML. If Prettier finds a tag closed in the wrong place, HTML Error shows the position, for example Line 3, column 1: Unexpected closing tag "div". It may happen when the tag has already been closed by another tag.
  5. Use Copy to take the result, or Download to get it as minified.html or formatted.html.