HTML formatter and minifier
Paste raw or minified HTML and get back cleanly indented markup — or collapse a formatted document back to a single line. It is useful for reading minified pages, tidying copy-pasted markup, and preparing snippets for documentation.
How it works
The formatter tokenises the markup into tags and text, then walks through tracking
the current nesting depth. Opening tags increase depth (and the next line is
indented), closing tags decrease it, and recognised void elements (img, br,
input, meta, link, hr and friends) never change depth so the lines after
them stay aligned. Each level is indented by your chosen unit — 2 spaces, 4 spaces
or a tab. The contents of pre, script, style and textarea are copied
verbatim, because whitespace is significant inside them. Minify mode does the
reverse: it strips comments and collapses the inter-tag whitespace.
Example
This one-line input:
<ul><li>One</li><li>Two</li></ul>
formats (at 2 spaces) to:
<ul>
<li>One</li>
<li>Two</li>
</ul>
It is privacy-first: the formatter is plain JavaScript that runs in your browser, so your markup never leaves your device. Only inter-tag whitespace changes — attributes, text and raw element contents are kept exactly.