HTML Formatter

Paste HTML and it is indented as you go, one tag or text run per line.

How it works

This is a tag-based indenter — plain string scanning, not a full HTML parser or a browser DOMParser. It tracks nesting depth as it walks through opening and closing tags, and re-emits one tag or text run per line. Void elements — br, img, input, hr, meta, link, area, base, col, embed, source, track, wbr — never open a new indent level and never expect a closing tag.