Indent HTML by tag depth, leaving pre, textarea, script and style contents untouched.
HTML Minifier
Remove HTML comments and collapse whitespace between tags, preserving conditional comments and raw-text elements.
- Free
- No sign-up
- Runs in your browser
Input
0 characters
Processed entirely in your browser. Nothing is uploaded.
Fill in Input to continue.
Enter your input to see the result
Everything happens on this device. No upload, no account, no network request.
How to use this tool
- 1
Paste your HTML and the result appears below, ready to copy or download.
- 2
Strings, comments and (where the language has them) regular expressions and template literals are preserved byte for byte, so your code cannot be corrupted.
Limits and caveats
Published up front rather than buried, because knowing where a tool stops is part of being able to trust it.
- Whitespace handling is judged from tag names, not computed CSS. An element whose display is changed by a stylesheet may keep a space it did not need, or - for a block element styled inline - lose one. The result is one byte either way, never reordered markup.
Questions about HTML Minifier
Could this change how my page looks?
It should not, and that is the one place a whitespace minifier usually gets wrong. Whitespace between inline elements is rendered: `<span>a</span> <span>b</span>` shows a space, and collapsing it runs the words together. So a single space is kept wherever either side of the gap is an inline or inline-block element, and removed only between block-level tags. It is conservative elsewhere too - it does not drop optional closing tags, shorten attributes or inline your CSS, because each of those can change behaviour.
Why keep a space after a block element then?
Because deciding whether a particular gap is rendered needs the CSS as well as the markup - `display` can make a div inline or a span block. Judging it from the tag name is an approximation, so it errs toward keeping the space. One byte is a better trade than a layout you have to debug.
Is this as good as Prettier?
No, and it is worth being clear why. This is a token-aware formatter: it knows where strings, comments and regular expressions begin and end, and re-indents around them. It is not a parser, so it cannot reflow a long expression across lines or normalise constructs. A full parser for one language is several hundred kilobytes, which would have to download before the tool could run. What it does guarantee is that it will never move a character out of a string or a comment - the property a regex-based formatter fails at.
Is my data sent anywhere?
No. This tool runs as JavaScript inside your browser tab. There is no network request carrying your input, nothing is written to a server log, and it keeps working with your connection switched off. You can confirm it in the browser’s network panel. That matters more here than elsewhere on the site: developer tools handle tokens, keys and production data.
Does the HTML Minifier work offline?
Yes. Once the page has loaded it runs entirely as JavaScript on your own device, so the HTML Minifier keeps working with the network switched off and nothing is ever sent to a server.
Related tools
Other tools you might reach for next.
Format CSS with one declaration per line and nested at-rules indented.
Minify CSS by removing comments and whitespace, dropping redundant semicolons and shortening zero values.
Format and indent JSON, with optional alphabetical key sorting and a precise syntax error when it will not parse.
Strip every byte of insignificant whitespace from JSON and report the saving.
Check that JSON is syntactically valid, report its structure, and flag duplicate keys that JSON.parse accepts silently.
Compare two JSON documents structurally, by path, distinguishing a type change from a value change.
Evaluate a JSONPath expression against a document and see every match with the path that produced it.