HTML Minifier & Beautifier
Compress HTML or re-indent it for reading — with whitespace that actually affects rendering left alone rather than silently collapsed.
Only whitespace and comments are ever changed. No HTML token is renamed, reordered or removed, so the output cannot behave differently from your input. That also means the size reduction is smaller than tools which rewrite your code — no variable mangling, no dead-code removal — no merged selectors, no collapsed shorthands — and because SQL needs whitespace between tokens, it can only be collapsed, never removed. This formats your source; it does not compile it. Your types are preserved, not stripped.
/*! banner comment is always kept, the usual
convention for a licence header.
Drop a HTML file here
Up to 4 MB · nothing uploaded
{{ error }}
{{ commentWarning }}
Verified — every token preserved
The output was re-tokenized and compared against the input: all {{ tokenCount }} code tokens are identical, in the same order. Only whitespace and comments differ.
Output rejected
The result did not survive the token check, so it was discarded rather than shown to you. This is a bug in the tool, not in your code — please treat the input as unformatted.
Your HTML is tokenized and reformatted entirely in your browser. Nothing you paste or drop is ever uploaded to a server.
Whitespace in HTML is not always decoration
Between two block-level tags it is pure layout and can go. Next to an inline element it is
rendered as a space: delete the gap in <span>a</span> <span>b</span>
and the two words run together. This tool collapses that kind of whitespace to a single space
rather than removing it, which is the difference between a smaller page and a visibly broken
one.
pre, textarea, script and style are left exactly alone
Whitespace inside <pre> and <textarea> is significant by
definition — reformatting it changes what the user sees. <script> and
<style> contents are different languages entirely. All four are captured
verbatim and never reflowed.
Comments are kept unless you say otherwise
Legacy conditional comments, framework hydration markers and build-tool placeholders all look like ordinary comments and all do something. Rather than delete them silently, this tool counts them and tells you, leaving the decision with you.
Beautifying only adds line breaks where they are safe
A newline is introduced where whitespace already existed, or between two block-level tags — never between two inline elements that were touching, because that would add a rendered space that was not in your input.
Frequently asked questions
Will minifying HTML change how my page looks?
Not if the tool is careful, which is the point of the restrictions here. Whitespace between two block-level tags is layout only and is removed. Whitespace next to an inline element or text is rendered as a space, so it is collapsed to a single space and never removed entirely.
What happens to pre, textarea and script content?
It is left exactly as written. Whitespace inside pre and textarea is significant by definition, and script and style contents are different languages, so the HTML pass treats all of them as opaque and never reflows them.
Why are comments kept by default?
Because some are load-bearing: legacy conditional comments and framework or build markers all look like ordinary comments. The tool reports how many it found and lets you remove them deliberately, rather than deleting them silently.
Can it beautify minified HTML?
Yes. It re-indents by nesting depth, but only introduces a line break where whitespace already existed or between two block-level tags — inserting one between two touching inline elements would add a rendered space that was not in your input.
Is my HTML uploaded anywhere?
No. Everything runs in your browser. Nothing is transmitted to a server.