XML Formatter

Cmd/Ctrl+Enter saves this input to history.

Advertisement

Paste XML, get consistently indented output instantly. Unlike a JSON formatter — where whitespace between tokens never means anything — an XML formatter has to be careful: only whitespace-only text between sibling elements is safe to throw away and re-indent.

Comments and CDATA sections are real content, not formatting noise, so this tool keeps both intact on every reformat. It also preserves whichever self-closing notation the original document used rather than rewriting it. Mixed content (text and elements interleaved in the same parent) is the one case where whitespace can become meaningful again — see the full guide below for that edge case.

Frequently asked questions

Is this XML formatter free to use?
Yes. It runs entirely in your browser — no signup, no data sent to a server.
Will formatting delete my comments or CDATA sections?
No. Comments and CDATA sections are preserved exactly as written — only whitespace-only text between sibling elements (pure indentation, not content) is re-indented.
Does it rewrite self-closing tags like <empty/> into <empty></empty>, or the other way around?
No. Both notations are semantically identical to any XML parser, so this tool preserves whichever one the original document used instead of normalizing it.
Is my XML uploaded anywhere?
No. Parsing and formatting happen locally in your browser tab — nothing is sent to a server.

Read the full guide for this tool →

Advertisement