EncryptCodecencryptcodec
Tools/Xml Prettifier

XML / HTML Prettifier

Format and prettify XML or HTML with proper indentation. Paste your markup and get a clean, readable output instantly.

All processing happens in your browser — nothing is sent to our servers

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.

How it works
XML / HTML Pretty-Printing
01Input

Raw XML or HTML markup — possibly minified or poorly indented

02Tokenize

Input split into tokens: opening tags, closing tags, self-closing tags, text content, comments, and declarations

03Tree structure

Tokens organized by nesting depth — each opening tag increases depth, each closing tag decreases it

04Indent

Each line indented by depth × indent size (2/4 spaces or tab) — nested elements visually nested

05Output

Well-formatted markup with consistent indentation — preserves all content and attributes

Spec: W3C XML 1.0, WHATWG HTML Living Standard

HTML is more forgiving than XML — void elements (br, img, input) don't need closing tags, and attribute quoting is optional. XML requires strict well-formedness.

Frequently Asked Questions