1. Home
  2. Developer
  3. HTML Beautifier & Minifier

HTML Beautifier & Minifier

Tidy HTML with proper indentation, or minify it by stripping whitespace.

For every format and option in one place, use Code Formatter and Checker →

Runs in your browser · No upload

Loading the beautifier…

Your HTML is processed as text only | never rendered or executed | and never uploaded.

How to use

  1. Paste HTML into the input | a full page, an email template, a CMS snippet.
  2. 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.
  3. Minify removes comments and collapses runs of whitespace and line breaks into a single space.
  4. Copy the result or download it as an .html file.

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.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.