Format HTML

Did you grab minified HTML via a site's "View page source", or paste an automatically generated fragment that's all on one unreadable line? Paste it here to get an indented version, one tag per line, before studying or editing it.

Note: this is a basic formatter (indentation by nesting level), not a full HTML parser like Prettier's. It doesn't fix improperly closed tags or syntax errors, and the content of <script> or <style> blocks isn't specifically reformatted.

Example:

How it works

Paste your minified or compact HTML into the field above and click "Format": the tool identifies opening, closing, and self-closing tags, places each tag on its own line, and indents 2 spaces per nesting level. Common self-closing tags (br, img, input, meta, link, hr, etc.) are recognized even without an explicit />.

Why doesn't my formatted HTML look exactly the same visually?

Reformatting adds line breaks and indentation whitespace between tags, which can slightly affect rendering if your CSS depends on whitespace between elements (rare, but possible with display: inline). The HTML content and structure remain identical: only the presentation of the source code changes.

Can this tool fix invalid HTML?

No. The formatter assumes your tags are broadly well-formed (opened and then closed in the right order). If it encounters a tag that's never closed or a truly unusual syntax, the result may be poorly indented. To validate the correctness of your HTML, use a dedicated validator alongside this tool.

Formatting runs 100% locally in your browser via WebAssembly : your HTML code is never sent to a server.