HTML Beautifier & Minifier

Pretty-print or minify HTML, with embedded CSS and JS, precise errors and size stats.

Runs locally · nothing uploaded
Input
Output

What it does

Paste a template, an email, a page saved from the browser or a one-line blob from a CMS and get clean, consistently indented HTML back, or the smallest safe version of it. The output updates as you type.

Features

  • Prettier formatting with 2 spaces, 4 spaces or tabs, a print width of your choice and one attribute per line for long tags.
  • Embedded code is formatted too: <style> blocks, <script> blocks and style="" attributes are pretty-printed with the CSS and JavaScript printers. Those extra parsers are only downloaded when your document contains them.
  • Whitespace sensitivity: Respect CSS display (the default) never adds or removes whitespace where it would change how inline elements render. Strict treats every element as inline, Ignore formats freely.
  • Minify removes comments (optional; conditional comments such as <!--[if IE]> are kept), collapses runs of whitespace to a single space and drops whitespace next to block-level tags such as div, p, li or td. The content of <pre>, <textarea>, <script>, <style> and <title> is copied byte for byte, and attribute values are never changed.
  • Precise errors: an unclosed tag or a stray closing tag is reported with its line and column, a code snippet with a caret and a Go to error button.
  • Size before and after, line counts and timing.

How to use it

  1. Paste HTML, open a file or drop one onto the input. Example loads a sample page.
  2. Choose Format or Minify and adjust the options.
  3. Copy or download the result. Ctrl+Enter runs immediately; untick Live for very large files.

The minifier is deliberately conservative: it does not remove optional tags or attribute quotes, and it does not rewrite inline CSS or JavaScript. As in most HTML minifiers, whitespace next to block-level tags is removed even if your CSS turns them into inline-block (for example a horizontal list of li items), which can close small gaps between them.

Privacy

Formatting and minifying run in your browser; only the pinned Prettier files are downloaded from a CDN. Your HTML is never uploaded. The last input is kept in local storage so a refresh doesn’t lose it. Use Clear to remove it.