Beautify minified HTML with 2-space, 4-space or tab indent, or minify it back to a single line. Preserves script, style and pre blocks.
Minified HTML is fast to transfer and impossible to read. A build pipeline that strips whitespace to save a few kilobytes leaves developers staring at a 4,000-character single line whenever they need to debug a layout or inspect a template. HTML Formatter & Beautifier restores the structure in one paste, indenting every block element to reflect the nesting depth of the document.
Minify mode runs the reverse trip: it removes comments, collapses all whitespace runs to a single space, and closes the gaps between tags. The character saving counter in the output header shows how many bytes the operation recovered. This is useful for confirming that a hand-edited template did not grow past its budget before committing.
Click Load Sample to paste a one-line HTML5 document containing a <head> with a stylesheet link, a <nav> with two list items, a <main> with a heading and a paragraph, and a <footer>. With 2 spaces indent active, the formatter expands this into a properly nested multi-line document — the <li> elements sit four levels deep inside html → body → nav → ul.
<meta>, <link>, <br> and <input> are never given a closing tag or a child indent level — a non-obvious rule that trips up formatters which treat every opening tag as a depth increase.<a>, <strong>, <span> etc.), and the content of <pre>, <script> and <style> blocks. Pre-formatted and script blocks are never reformatted because whitespace inside them is semantically significant.< character may produce mis-indented output rather than an error. The message Could not parse the HTML — check for unclosed tags or malformed attributes. appears only when the tokeniser throws outright.Mode
Indent
Paste HTML above, or hit Load Sample to beautify a complete page skeleton.