HTML Beautifier
An HTML beautifier indents nested tags according to how deeply they’re nested, turning minified or collapsed HTML into a readable structure — the counterpart to this site’s remove-html-tags tool, which strips tags rather than formatting them. Void elements like `<img>` and `<br>` never have a closing tag or children by definition in the HTML spec, so counting them as a level of nesting would push every subsequent sibling tag one indent level deeper than it should be — a common bug in naive tag-depth counters that this tool specifically avoids.
How it works
- Paste HTML.
- Read the indented output, one line per tag or text node.
- Copy the result with the Copy result button.
Formula Tag-depth tracking via a stack; void elements (br, img, input, ...) and self-closing tags don’t increase depth
Frequently asked questions
Does this validate my HTML?
No — it indents by tag structure but does not check for mismatched or invalid tags. An unmatched closing tag is handled gracefully (indentation floors at zero) rather than crashing.
Why don’t <img> or <br> tags increase the indent level?
They’re "void elements" that never have a closing tag or children, so treating them as nesting would push every tag after them one level too deep.
Does this handle <script> or <style> content specially?
No — their contents are treated as plain text nodes like any other tag’s content, not re-formatted as JavaScript/CSS.
Are comments preserved?
Yes — HTML comments are kept at their current indent level, unaffected by nesting.
Is my markup uploaded anywhere?
No. Formatting runs entirely in your browser.