piapia123
en

HTML Formatter & Minifier

Formatting

Everything runs locally in your browser — nothing is uploaded

Input
Output

Expand a minified HTML document into an indented structure. Unlike formatters that break at every tag, this one looks at the text: once an element contains actual text, its whole subtree stays inline, because a newline in HTML is a real space. Moving the <b> in <p>a<b>x</b> onto its own line turns the rendered result from "ax" into "a x". For the same reason no space is invented where the source had none.

Features

  • Indent by tag level with 2-space, 4-space or tab indentation
  • Knows the void elements (br, img, meta, input, link and friends), so following content is not indented an extra level
  • Keeps text and inline tags on one line and only inserts a space where the source had one
  • Preserves the content of script, style, pre and textarea, with the closing tag written flush against it
  • Comments and the DOCTYPE get their own lines, and whitespace runs inside tags collapse to a single space
  • Whitespace inside attribute values is preserved, and a > inside a value does not end the tag
  • Minify mode removes the whitespace between tags and the comments
  • No syntax validation: unclosed tags are indented as best they can rather than rejected

How to use

  1. Paste your HTML into the input box
  2. Pick the mode and indentation
  3. Press Ctrl/⌘ + Enter or click Run
  4. Click Copy to take the result

FAQ

Why did minifying remove some spaces from my page?
Minify deletes the whitespace between tags. That is usually harmless, but the space between inline elements is a real gap when rendered, so <span>a</span> <span>b</span> becomes "ab". Use format mode when that gap matters.
Why is the text not broken across lines?
Breaking it would insert real spaces and change what the browser renders. Line breaks are only added at structural positions; text stays where it was.
Is the content of script and pre reformatted?
No. Those elements are carried through verbatim, with the closing tag written right after the content, so nothing inside their code or layout is disturbed for the sake of tidiness.
Is my HTML uploaded anywhere?
No. Everything runs in your browser memory, the page makes no network requests, and it works offline.

Related tools