All tools

HTML Beautifier / Minifier

Format HTML or strip whitespace.

<!DOCTYPE html>
<html>
  <head>
    <title>
      Hi
    </title>
  </head>
  <body>
    <div class="container">
      <h1>
        Hello
      </h1>
      <p>
        Some
        <b>
          bold
        </b>
        text
      </p>
      <ul>
        <li>
          One
        </li>
        <li>
          Two
        </li>
      </ul>
    </div>
  </body>
</html>

Beautify uses 2-space or 4-space indent and respects pre, textarea, script, and style content. Minify strips comments and collapses whitespace. For production minification, use a tool that also rewrites attribute quotes and inline event handlers.

About

Beautify with 2 or 4-space indent, respecting pre, textarea, script, and style content. Minify strips comments and collapses whitespace. Useful for cleaning up a saved-as-HTML page or shrinking inline templates.

How to use

  1. Pick beautify or minify.
  2. Paste HTML.

FAQ

Will minification break my page?+

Whitespace inside pre and textarea is preserved. Inline JavaScript that depends on newlines could break. Test before deploying minified HTML.