How to use
- Paste HTML into the input | a full page, an email template, a CMS snippet.
- Beautify indents tags by nesting level and also formats inline
<script>and<style>as JavaScript and CSS. Turn on One attribute per line for tags with many attributes. - Minify removes comments and collapses runs of whitespace and line breaks into a single space.
- Copy the result or download it as an
.htmlfile.
Minify rules
In HTML, a run of spaces, tabs and line breaks renders as one space (with CSS white-space: normal). Collapsing to one space therefore looks identical, while removing it entirely can glue words together.
| Target | Handling |
|---|---|
Ordinary comments <!-- note --> |
Removed (optional) |
IE conditional comments <!--[if IE]>…<![endif]--> |
Kept |
| Runs of whitespace and line breaks | One space |
Whitespace inside tags <a href="x" > |
<a href="x"> |
Contents of <pre> and <textarea> |
Untouched (whitespace matters) |
Contents of <script> and <style> |
Untouched |
Attribute values "a b" |
Untouched |
“Also remove spaces around block tags” removes even that single space next to block tags such as <div>, <p> and <li>. Whitespace at block boundaries normally doesn’t render, but between elements styled display: inline-block (like li items in a horizontal menu) it changes the gap | so the option is off by default.
Things to watch out for
- Beautify changes only whitespace. Inline elements that touch in the source, like
<span>a</span><span>b</span>, stay together, because a line break between them would add a visible space. - This tool doesn’t fix broken HTML. A missing closing tag shows up as indentation that drifts | a handy clue for finding it.
- Keep your original before minifying; removed comments don’t come back when you beautify again.
FAQ
Is the HTML I paste executed?
No. It’s handled purely as text | never rendered and no scripts run | and it isn’t uploaded.
Can I convert HTML to Markdown?
Use HTML to Markdown. For CSS or JavaScript on their own, see the CSS Beautifier & Minifier and the JavaScript Beautifier & Minifier.