HTML Minifier / Beautifier
Minify HTML with 8 configurable options including inline CSS/JS, or beautify minified HTML with 2-space, 4-space, or tab indent. Browser-based.
What is the HTML Minifier / Beautifier?
An HTML minifier shrinks an HTML document by removing comments, collapsing whitespace, and (optionally) tightening boolean attributes, attribute quotes, and inline CSS or JavaScript. The browser parses the minified file identically, so the user sees the same page; the difference is fewer bytes shipped over the network. Beautify reverses the process for editing.
How to use the HTML Minifier / Beautifier
- 1
Paste or upload HTML
Drop HTML into the input pane, drag a .html file onto it, or click Upload. Load Sample drops in an example.
- 2
Pick the minification options
Eight independent toggles: remove comments, collapse whitespace, collapse boolean attrs (disabled="disabled" becomes disabled), minify inline CSS, minify inline JS, remove empty attrs, remove attr quotes, remove optional closing tags.
- 3
Click Minify or Beautify
Minify produces the smallest valid HTML with your chosen options. Beautify takes minified HTML and adds indentation (2 spaces, 4 spaces, or tab).
- 4
Copy or download
Copy sends the result to your clipboard. Download saves it as <name>.min.html or <name>.formatted.html.
Frequently Asked Questions
What does HTML minification do?
It removes the bytes a browser doesn't need: HTML comments, whitespace between tags, indentation, optional closing tags, and (with the matching toggles) attribute quotes that aren't needed and boolean attributes that don't need a value. The rendered page stays the same; the file gets smaller.
Can I unminify HTML?
Yes. Click Beautify and the minifier reformats the HTML with proper line breaks and indentation (2 spaces by default, switchable to 4 spaces or tab). Content inside <pre>, <script>, <style>, and <textarea> is preserved exactly, since reformatting those would change behavior or visible output.
What are the minification options?
Eight: remove HTML comments, collapse whitespace, collapse boolean attributes (disabled="disabled" → disabled), minify inline <style> blocks, minify inline <script> blocks (block comments and whitespace only), remove empty attributes (class="", id=""), remove attribute quotes when safe, and remove optional closing tags (</p>, </li>, </td>, etc.).
Is content inside script and style tags preserved?
Yes. The contents of <pre>, <script>, <style>, and <textarea> are extracted before minification and put back unchanged after. Inline CSS and JS get minified separately if you've toggled those options on, but the protection from whitespace collapse is automatic for all four tags.