XML Formatter & Beautifier
Paste minified or messy XML and get it indented or minified. It runs in your browser, and only the whitespace between tags changes.
Ctrl+Enter also works. Your XML is processed in your browser and never sent to a server.
A Formatter That Leaves Your Text Alone
The simple way to pretty print XML is to put every tag and every piece of text on its own line, indented by depth. That is harmless between child elements, and it breaks any element that mixes text and tags. Run this paragraph through it:
You wrote
<p>Hello <b>world</b>, again!</p>
Every tag and every piece of text on its own line
<p> Hello <b>world</b> , again! </p>
The text of that paragraph is now “Hello”, a line break, “world”, another line break and “, again!”. An RSS reader, an XSLT stylesheet or a translation tool sees exactly that. This formatter indents an element only when its children are all elements. As soon as text appears among them, the element is copied as written, and the result tells you how many were.
What Is Never Touched
| Kept as written | Example | Why |
|---|---|---|
| Text mixed with tags | <p>Hello <b>world</b>!</p> | A line break before <b> would become part of the sentence. The element is copied as written. |
| An element holding only whitespace | <code> </code> | Those two spaces are its content. They stay. |
| xml:space="preserve" | <pre xml:space="preserve"> <b/> </pre> | The document asks for its whitespace to be kept, so the whole element is left alone. |
| CDATA sections | <![CDATA[ a < b ]]> | Character data, copied byte for byte, and the element around it is not re-indented. |
| Attribute values and quotes | title='a > b' | Single or double quotes, line breaks inside a value, entities: all kept. Attribute order is never changed. |
| Comments, processing instructions, the DOCTYPE | <!DOCTYPE note [<!ENTITY gt2 ">">]> | Copied verbatim, internal subset included. Comments go only if you tick Remove comments. |
What does change is whitespace and nothing else: indentation between child elements, the spacing inside tags (one space between attributes, none around = or before />), and Windows line endings, which become LF exactly as an XML parser reads them. Delete every space, tab and line break from the input and from the output, and you get the same text.
What You Can Do With It
Read a sitemap or a feed
Sitemaps and RSS feeds are usually served on one line. Paste one in and read it as a tree of <url> or <item> entries. Your own sitemap is at /sitemap.xml.
Tidy a config file
Maven pom.xml, Android manifests, .csproj files and Spring configs: re-indent with 2 spaces, 4 spaces or tabs to match the rest of the repository.
Inspect an SVG or a SOAP response
Exported SVG and API responses arrive minified. Format them to find the element you need, then minify again before shipping.
Find the broken tag
Invalid XML is not formatted. You get the line and column of the first error, a click that selects it, and the guide that explains the fix.
Formatting or Validating?
Both tools refuse XML that is not well-formed, and they use the same check, so they never disagree. This page is for shaping a document: indentation, minifying and comments. If you only need to know whether a file parses and where it breaks, the XML Validator is the shorter path. When either one finds an error, the XML error guides show the wrong and right version side by side, from unclosed tags to unescaped characters. For JSON, the JSON formatter makes the same promise: only whitespace changes.