What this tool does
The HTML Formatter re-indents messy or minified HTML so its structure is easy to read, and can also minify clean HTML back down to compact markup. Choose your indentation — two spaces, four spaces, or tabs — and the tool prints each element at a depth that reflects its nesting.
How it works
The formatter tokenises your HTML into tags, text, comments, and doctype, then prints each meaningful node on its own line, increasing the indent for every open tag and decreasing it for every close tag. Void elements and the verbatim content of pre, script, style, and textarea are handled specially so the output stays correct. The logic is a pure function — the same input always produces the same output.
Privacy
Everything runs locally in your browser. No values are uploaded, logged, or stored.