EN
My tools

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.

Output
Formatted XML

Well-formed · 12 elements · 5 attributes · depth 4 · 429 → 486 characters

My tools →
Advertisement

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

  1. Paste the XML; the formatted version appears as you type.
  2. Choose 2 spaces, 4 spaces or tabs.
  3. Optionally put each attribute on its own line, write empty elements as <tag/>, or drop comments.
  4. 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 &amp;), an unquoted attribute, two root elements, or an HTML entity such as &nbsp; 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:

Cite or embed this tool
APA

kakaoCalc. (2026, November 8). XML Formatter. https://kakao.mobile/tools/xml-formatter/

MLA

“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

Advertisement