XML Formatter
Pretty-print XML with configurable indentation and well-formedness checks.
Nothing formatted yet
Paste XML and press Format. Comments, CDATA sections and mixed text content are preserved exactly, so formatting cannot change what it means.
Runs entirely in your browser. Your data isn't uploaded — this page makes no network request with anything you type, which you can verify in your browser's network tab. How this works.
What is the XML Formatter?
XML that arrives minified — a SOAP response, an RSS feed, an OOXML fragment, a Maven pom.xml pasted from a log — is unreadable until something re-indents it. This formatter parses the document first, so formatting doubles as a well-formedness check: a mismatched or unclosed tag is reported by line and column instead of producing mangled or silently wrong output.
Elements that mix real text with markup, such as a sentence containing an inline <b> or <a> tag, are left exactly as they read rather than reflowed — reindenting them would insert whitespace a consumer could treat as meaningful, which is the one thing a formatter must never do to a document.
How to use it
- Paste your XML into the editor, or use Upload to load an .xml file.
- Choose an indentation style — 2 spaces, 4 spaces, or tabs.
- Choose whether empty elements self-close (<tag/>) or stay as a pair (<tag></tag>).
- Press Format (or Ctrl/Cmd + Enter). The result appears on the right.
- Use Copy to put the formatted XML on your clipboard, or Download to save it.
Example
A minified service config, formatted with 2-space indentation.
<?xml version="1.0" encoding="UTF-8"?><service name="payments-api"><replicas>3</replicas><endpoints><endpoint path="/charge" method="POST"/><endpoint path="/refund" method="POST"/></endpoints></service>
<?xml version="1.0" encoding="UTF-8"?>
<service name="payments-api">
<replicas>3</replicas>
<endpoints>
<endpoint path="/charge" method="POST"/>
<endpoint path="/refund" method="POST"/>
</endpoints>
</service>
Features
- 2-space, 4-space and tab indentation
- Well-formedness checked while parsing, with exact line and column on error
- Mismatched and unclosed tags reported by name and the line they were opened on
- Comments, CDATA sections and processing instructions preserved exactly
- Mixed text-and-markup content never reindented
- Duplicate attributes on one element reported as an error, per the XML spec