XML / HTML Prettifier
Format and prettify XML or HTML with proper indentation. Paste your markup and get a clean, readable output instantly.
How the formatter works
This tool parses your XML or HTML and re-indents each tag based on its nesting depth. Self-closing tags like <br /> stay on one line. Elements with short text content like <name>value</name> are kept inline for readability. Comments, CDATA sections, and processing instructions are preserved.
Raw XML or HTML markup — possibly minified or poorly indented
Input split into tokens: opening tags, closing tags, self-closing tags, text content, comments, and declarations
Tokens organized by nesting depth — each opening tag increases depth, each closing tag decreases it
Each line indented by depth × indent size (2/4 spaces or tab) — nested elements visually nested
Well-formatted markup with consistent indentation — preserves all content and attributes
Spec: W3C XML 1.0, WHATWG HTML Living Standard