HTML Formatter
Format and beautify HTML source code so tags and nested structure are easier to inspect and edit.
HTML Formatter online
Re-indent HTML so nesting is visible at a glance — one tag per line, two spaces per depth level — for markup that arrived as a single line or a tangled paste.
How to use this tool
- Paste your HTML into the input box.
- Click Run Tool. The markup is split at tag boundaries and indented by nesting depth.
- Copy the formatted HTML from the result panel.
Common uses
Reading view-source output and email templates, untangling markup generated by a CMS or a visual builder, checking whether a stray closing tag broke the nesting, and preparing HTML for a readable diff or code review.
How it works
The formatter splits the document wherever a tag closes and the next opens, then walks the lines tracking depth: an opening tag increases the indent for what follows, a closing tag decreases it, and self-closing tags, comments and the doctype leave depth unchanged. Each line is trimmed and re-padded with two spaces per level. It is a layout tool, not a parser — it does not validate, repair or re-order anything, so the structure it reveals is exactly the structure you have.
Worked example
The one-line fragment
<ul><li>One</li><li>Two</li></ul>
becomes
<ul>
<li>
One
</li>
<li>
Two
</li>
</ul>Text sits on its own line between its tags — verbose, but the nesting mistakes (an unclosed <li>, say) become impossible to miss.
Privacy and browser processing
Your HTML is formatted in your browser with JavaScript — it is never uploaded or stored.
Frequently asked questions
Why is text on its own line?
Splitting happens at every tag boundary, so an element's text lands between its opening and closing tags on separate lines. It reads longer, but the depth column stays perfectly aligned, which is what makes structural errors visible.
Does it fix broken HTML?
No. It indents the markup you give it; an unclosed tag simply keeps the indent deep for the rest of the file — which is precisely how you spot it. Repair is a manual edit once the layout shows you where.