HTML Formatter

Prettify and minify HTML markup using the browser's built-in parser — no uploads, no dependencies.

Runs locally
Input HTML
Output

What is an HTML formatter?

An HTML formatter takes raw, minified, or poorly-indented HTML and rewrites it with consistent indentation so the structure is easy to read. Under the hood it uses the browser's own DOMParser to parse the HTML correctly (handling optional closing tags, implicit elements, and all the quirks of the HTML5 spec), then re-serialises the DOM tree with your chosen indent width. The minifier strips comments and collapses whitespace to reduce file size for production delivery.

How to use this tool

  1. 1 Paste your HTML into the Input panel.
  2. 2 Choose Prettify to add consistent indentation, or Minify to strip all optional whitespace.
  3. 3 Adjust the indent width (default 2 spaces) to match your project style.
  4. 4 Copy the result or clear the input to start fresh.

Frequently asked questions

Does this validate my HTML?

The browser's DOMParser is lenient — it corrects malformed HTML rather than rejecting it (by closing unclosed tags, inserting implicit elements). If you need strict validation, use the W3C Markup Validator.

Will comments be kept after minification?

No. The minifier strips all HTML comments to reduce file size. If you need comments preserved in production (for conditional IE markup etc.), use Prettify mode instead.

Why might the output differ slightly from my input?

The formatter round-trips through the DOM, so it may add implicit elements (like a tbody inside a table), close unclosed tags, and entity-encode certain characters — all of which browsers do anyway when they parse your HTML.

Is my HTML uploaded to a server?

No. Everything runs locally using the browser's DOMParser and native DOM APIs. Nothing leaves your machine.

What indent widths are supported?

Any integer from 1 to 8 spaces. 2 spaces is the most common for HTML; 4 spaces is common in some older projects. Tabs are not currently supported.