HTML Prettifier

100% Client-Side
Privacy: 100% Client-Side. Your data never leaves this browser tab. Processing uses Web APIs and client-side libraries only.

Pretty-print or minify HTML without changing how it renders, see what a browser would repair, and sanitize with DOMPurify — nothing leaves your browser.

<div class="card">
  <h1 onclick="alert(1)">Hello</h1>
  <script>evil()</script>
  <p>stbox</p>
</div>

Only whitespace that doesn't render is changed: scripts, styles, <pre> and <textarea> stay as written, inline text stays on its line, and optional end tags aren't added. Minify also removes the whitespace between block elements.

What does the HTML prettifier do?

It re-indents HTML following the WHATWG parsing rules: block elements go on their own lines, while inline text, <pre>, <textarea>, scripts and styles keep their exact whitespace, and optional end tags (</li>, </p>, </td>) are understood rather than added. Only whitespace that doesn't render is changed, so the page looks the same.

It also lists what a browser would repair without telling you: unclosed or stray tags, duplicate attributes, <div/> written as if self-closing. Sanitizing with DOMPurify strips scripts and event handlers from untrusted markup.

How to use this tool

  1. Paste HTML into the editor.
  2. Read the prettified or minified output and any warnings.
  3. Sanitize untrusted markup with DOMPurify, then copy the result.

Frequently asked questions

Will formatting change how my page renders?

No. Whitespace is only added or removed next to block-level elements, where it doesn't render. Minify also removes it between blocks, which can matter if CSS makes those elements inline.

Is HTML uploaded?

No. Formatting and sanitization run 100% in the browser.