HTML
HTML Formatter
Minify and beautify HTML.
About HTML formatting
HTML is the markup that structures every web page. Minifying strips whitespace, comments, and redundant syntax to shrink the file for production; beautifying re-indents it so nested elements are easy to read and edit.
Whitespace inside <pre>, <textarea>, and a handful of other elements is significant to how the page renders, so a naive minifier that strips all whitespace indiscriminately would visibly break them. This one is whitespace-aware: it collapses insignificant space between ordinary tags while leaving whitespace-sensitive elements untouched. Ordinary <!-- comments --> are removed, but the old conditional-comment syntax some legacy sites still use for Internet Explorer, like <!--[if IE]>...<![endif]-->, is left completely intact, since it isn't a true comment but a directive that happens to be written inside comment syntax. Boolean attributes such as checked="checked" are also left exactly as written rather than shortened to their bare form.
Where you'll run into it
- Shrinking a page's markup before deploying it to production
- Pretty-printing markup returned by an API or server-side render for debugging
- Cleaning up HTML copied from a CMS export or another site
- Standardizing indentation before reviewing a markup diff
Frequently asked
Will minifying change how my page looks?
No. Only whitespace, comments, and redundant syntax are removed — the rendered result is the same.
Does this also minify inline CSS and JavaScript?
Yes. CSS inside <style> tags and JavaScript inside <script> tags are minified too, along with the surrounding markup.
Is my HTML stored?
No. Conversion happens on the server for that one request only; nothing is logged or kept afterward.
What happens to whitespace inside <pre> or <textarea>?
It's left alone. Those elements render their contents exactly as written, including line breaks and indentation, so collapsing whitespace inside them would change how the page actually looks — unlike the whitespace between ordinary tags, which is visually insignificant and safe to strip. This tool detects whitespace-sensitive elements and skips them specifically to avoid that.