About HTML Formatting
HTML looks simple but is deceptively hard to format correctly. Unlike JSON or YAML, HTML has rules that the formatter has to respect or it will silently break the document.
Void elements
Tags like <br>, <img>, <input>, <meta>, <link>, and <hr> cannot have closing tags. A naive formatter that assumes every opening tag needs a </tag> will produce invalid HTML. This tool knows the full list of void elements and handles them correctly. You can pick HTML5 style (<br>) or XHTML self-closing (<br/>).
Whitespace-sensitive content
Inside <pre> and <textarea>, every space, tab, and newline is meaningful — collapsing them changes what the user sees. The formatter leaves the content of these tags untouched in both Beautify and Minify modes.
<script> and <style> blocks
The content of <script> and <style> tags is not HTML — it's JavaScript and CSS. Re-indenting it with an HTML formatter would mangle it. These blocks are preserved as-is. If you need to format JS or CSS, use the dedicated JS Minifier or CSS Minifier.
Minification trade-offs
Removing optional closing tags (</li>, </p>, </td>) can save bytes, but some older tooling and email clients don't handle it well. That option is off by default. Unquoting attributes is similar — valid per HTML5, but disabled by default because edge cases (spaces, equals signs, quotes inside the value) can break downstream parsers.