HTML Formatter
Format and beautify indented HTML: normalize whitespace, stack attributes, and make nested tags readable. Handles void elements and inline text sensibly so output stays valid.
Paste HTML and the formatter rewrites it with consistent two-space indentation, one attribute per line for wide tags, and no whitespace churn inside inline text nodes.
HTML input
Formatted
!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"><title>Demo</title>
</head>
<body>
<main>
<h1>
Hello
</h1>
<p>
This is a<strong>bold</strong>paragraph<br>with a line break.
</p>
<ul>
<li>
One
</li>
<li>
Two
</li>
</ul>
<!-- a comment -->
RAW0
</main>
</body>
</html>319 bytes → 417 bytes · grew 98 bytes · formatting happens locally
Frequently asked questions
Will the formatter break my existing markup?
It only adds whitespace around structural elements and never rewrites attributes or text content, so the meaning of the markup is preserved.
Does it handle inline elements?
Yes — spans, links and emphasis stay on one line with their neighbours to avoid creating phantom whitespace in rendered output.