XML Formatter
Pretty-print and validate XML instantly. Indent with 2 spaces, 4 spaces or tabs, collapse text content onto one line, self-close empty tags, strip comments, and get a clear message when the markup is malformed.
Input
Settings
Keep content on the same line as its element, whenever the element holds at least one text node.
Output
Guides
Paste raw, minified or badly indented XML and get clean, readable markup back instantly. The XML Formatter re-indents every element, keeps attributes intact, and tells you exactly where the document breaks if it is malformed — no sign-up, no upload to a server.
How to use it
- Paste your XML into the input box, or drop an
.xmlfile onto the uploader (its contents land in the editor). - Pick your indentation: 2 spaces, 4 spaces or tabs.
- Toggle the settings you want, and copy or download the formatted result.
Formatting runs as you type, so you see the shape of the document immediately.
Settings
- Indentation — 2 spaces, 4 spaces or a tab per nesting level.
- Collapse content — keeps an element's content on the same line as its tags whenever the element holds at least one text node.
<p>Hello <b>world</b></p>stays on one line instead of exploding across four. - Self-closing for empty tags — rewrites
<notes></notes>as<notes/>. - Remove comments — strips every
<!-- ... -->block from the output.
Text-only elements such as <title>XML Basics</title> always stay on one line, with or without the collapse option.
Does it validate my XML?
It checks that the document is well-formed: every tag is closed, closing tags match their opening tags, and comments, CDATA sections and processing instructions are terminated. If something is wrong you get a message naming the problem (for example, "mismatched closing tag: expected </to>, found </from>") instead of silently broken output. It does not validate against a DTD or an XSD schema — well-formedness only.
Is my XML sent anywhere?
No. The formatter runs entirely in your browser: your document never leaves your machine, is never logged, and is never stored. That makes it safe for configuration files, SOAP payloads, invoices and other sensitive documents.
What about declarations, DOCTYPE, CDATA and comments?
All preserved. The <?xml version="1.0"?> declaration stays on its own line, DOCTYPE declarations and processing instructions are kept, and CDATA sections are copied through byte-for-byte so escaped content is never mangled. Comments are kept unless you turn on Remove comments.
Can I format an RSS feed, SVG, SOAP response or POM file?
Yes — they are all XML. Anything well-formed works: RSS and Atom feeds, SVG images, SOAP envelopes, Maven pom.xml, Android layouts, sitemaps and .plist files.
Does formatting change my data?
Structure and values are preserved. Whitespace between elements is layout, not data, so it is rewritten to match your chosen indentation, and runs of whitespace inside text nodes are collapsed to a single space. If you need byte-exact whitespace inside a text node, wrap it in a CDATA section, which is copied verbatim.
How do I go the other way?
Use the XML Minifier to strip the formatting back out again before shipping the document over the wire.