HTML Beautify/Minify
Format or minify HTML markup. Beautify adds indentation for readability; minify removes whitespace to reduce file size.Overview
The HTML Beautify/Minify tool processes HTML with two modes:- Beautify — Adds indentation, line breaks, and proper nesting
- Minify — Removes comments, collapses whitespace, and strips unnecessary characters
Use Cases
Code readability
Format minified or machine-generated HTML for easier reading and editing
Production optimization
Minify HTML to reduce page size and improve load times
Code review
Standardize indentation for diffs and version control
Template cleanup
Clean up HTML from WYSIWYG editors or CMS exports
Actions
- Beautify
- Minify
Adds indentation (2 spaces per level) and line breaks. Respects void elements like Output:
<br>, <img>, <input>.Input:Implementation Details
Beautify Algorithm
- Split HTML into tokens at tag boundaries
- Track indentation level with a counter
- Indent closing tags, self-closing tags, and opening tags
- Increase indentation after opening tags (unless self-closing or void)
- Decrease indentation before closing tags
lib/tools/engine.ts:183-220
Key logic
Minify Algorithm
- Remove HTML comments (
<!-- ... -->) - Collapse consecutive whitespace to single spaces
- Remove spaces between tags (
> <→><) - Strip leading/trailing whitespace
lib/tools/engine.ts:222-231
Key logic
Void Elements
The tool recognizes these HTML5 void elements (no closing tag required):<area>,<base>,<br>,<col>,<embed>,<hr>,<img>,<input><link>,<meta>,<param>,<source>,<track>,<wbr>
Keyboard Shortcuts
Cmd/Ctrl+Enter— Beautify (default)Cmd/Ctrl+Shift+C— Copy outputCmd/Ctrl+Shift+S— Download output
Related Tools
CSS Beautify/Minify
Format or minify CSS stylesheets
JS Beautify/Minify
Format or minify JavaScript/TypeScript
HTML Preview
Render HTML safely in an iframe
HTML to JSX
Convert HTML to React JSX