XML Formatter
Pretty-print or minify XML with 2, 4 or tab indents. Keeps mixed content, CDATA and xml:space="preserve" intact; errors show line and column.
Well-formed · 12 elements · 5 attributes · depth 4 · 429 → 486 characters
Paste XML that arrived on one line — a SOAP response, an RSS feed, an SVG export, a sitemap, Android or XAML layout — and get it back indented one element per line. The formatter first checks that the document is well-formed according to the XML 1.0 rules, so a missing end tag or a stray ampersand is pointed out with its line and column instead of producing broken output.
How to use this tool
- Paste the XML; the formatted version appears as you type.
- Choose 2 spaces, 4 spaces or tabs.
- Optionally put each attribute on its own line, write empty elements as
<tag/>, or drop comments. - Switch to Minify to remove the indentation again for transport.
Formula
element-only content → one child per line, indented one level; mixed content, CDATA and xml:space="preserve" → kept exactly
Whitespace between elements is not data when an element contains only other elements, so it can be re-indented safely. When text sits next to elements (mixed content, as in XHTML or DocBook) or an element asks for xml:space="preserve", every space may matter, so that element is copied as written. Attribute values, entity references and quote characters are never changed.
Example
The sample catalog arrives on one line. Formatted with 2 spaces it becomes 16 lines: <catalog> at the margin, each <book id="…"> two spaces in, and <author>, <title> and <price> four spaces in. The description mixes text with <em>with</em>, so it stays on a single line exactly as written, and <reviews/> stays self-closed.
Frequently asked questions
Why was one element left on a single line?
It contains text mixed with child elements, or CDATA, or xml:space="preserve". Adding line breaks there would change the document's text content, so the formatter leaves it alone.
What makes XML not well-formed?
The common causes are an end tag that does not match its start tag, a bare & (write &), an unquoted attribute, two root elements, or an HTML entity such as that XML does not predefine. The error message names the rule and the position.
Does it validate against a schema?
No — it checks well-formedness only. DTD and XSD validation need the schema files and are not done; use the XML validator for a detailed well-formedness report.
Is my XML uploaded?
No. Parsing and formatting happen in your browser.
Sources
Last updated:
Page address with these inputs: https://kakao.mobile/tools/xml-formatter/
Cite or embed this tool
kakaoCalc. (2026, November 8). XML Formatter. https://kakao.mobile/tools/xml-formatter/
“XML Formatter.” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/xml-formatter/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms