HTML Formatter: Format and Minify HTML Markup

Pretty-print or minify HTML documents and fragments in this browser. Parsing uses DOMParser as text/html, so the result is the HTML DOM — not an XML round-trip. Script, style, textarea, and pre content stays intact. Markup is never executed and is written to the output as text only.

Format options
Load file

Drop a .html or .txt file here. Client-only FileReader. Nothing is uploaded.

Output is assigned as plain text. User HTML is never inserted as live DOM nodes.

Paste HTML and press Pretty-print or Minify. Work stays in this browser.
HTML is not XML — what this tool does

The HTML Living Standard parser always builds a document tree. It lowercases HTML tag names, implies missing html/head/body tags, auto-closes elements, moves some tags, and ignores end tags on void elements. This formatter serializes that tree. It is a pretty-printer and minifier, not a validator and not an XML canonicalizer.

  • Void elements (area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr) are written without a closing tag.
  • Script, style, textarea, title, and pre content is preserved. Inline JavaScript is not executed.
  • SVG and MathML are HTML foreign content after the HTML parser — not a true XML round-trip. Namespace prefixes and XML self-closing rules are only approximated.
  • There is no live preview iframe. Output is text in a textarea so scripts, images, and event handlers cannot run on this page.