XML Formatter Online

Paste XML and get it back indented, highlighted and easy to read, or minified to one line. It is for anyone reading API and SOAP responses, RSS and Atom feeds, sitemaps, SVG, or project files such as pom.xml and .csproj: choose 2 spaces, 4 spaces or tabs, or explore the document as a collapsible tree.

The check runs in your browser as you type, so nothing is uploaded and you do not need an account. If the XML is not well-formed, DevPrix shows the line and column of the first problem, such as a mismatched tag, an unescaped & or an undeclared namespace prefix, marks the line, and suggests a fix.

InputPaste, type or drop an .xml file
Output
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Example Engineering Blog</title>
    <link>https://example.com/blog</link>
    <atom:link href="https://example.com/blog/feed.xml" rel="self" type="application/rss+xml"/>
    <description>Release notes &amp; deep dives</description>
    <!-- newest first -->
    <item>
      <title>Caching build outputs between CI runs</title>
      <link>https://example.com/blog/ci-cache</link>
      <guid isPermaLink="true">https://example.com/blog/ci-cache</guid>
      <dc:creator>Ada Lovelace</dc:creator>
      <category>ci</category>
      <pubDate>Thu, 22 Oct 2026 13:30:38 GMT</pubDate>
      <description><![CDATA[How we reuse <em>build outputs</em> across pipelines.]]></description>
    </item>
  </channel>
</rss>
Well-formed XML14 elements5 attributesDepth 4788 B → 880 BProcessed locally

How to use it

  1. Paste XML into Input, or open or drop an .xml file; it is checked as you type.
  2. Choose Formatted, Minified or Tree, an indent, and whether to self-close empty elements.
  3. Press Format (⌘↵) to apply the result to your input, then copy, download or send it to another tool.

Related tools

Data Format ViewerFormatJSON FormatterFormatYAML / JSON ConverterConvertHTML Entity EncoderWeb & API

Next: convert the XML to JSON or YAML in the Data Format Viewer, compare two versions in the Text Diff Checker, or escape it for a string literal with String Escape.

What this tool does

The tool reads your text with its own checker for XML 1.0 and Namespaces 1.0. It checks that every element is closed and correctly nested, that there is exactly one root element, that attributes are quoted and not repeated, that & and < are escaped, that entities are defined, that comments, CDATA sections and processing instructions are closed, that the <?xml … ?> declaration comes first, and that every namespace prefix is declared. Formatting changes only the whitespace between tags: element and attribute names, attribute order and quotes, comments, CDATA sections, processing instructions and the DOCTYPE stay as written. An element that contains text, such as <p>Some <b>bold</b> text</p>, is copied exactly, so mixed content keeps its meaning, and so is anything inside xml:space="preserve". Whitespace-only text between tags is treated as indentation and replaced; Minified mode removes it. Empty elements stay as written unless you turn on Self-close empty, which writes <a></a> as <a/>. The tool checks well-formedness only: it does not validate against a DTD or an XML Schema (XSD).

Example input and output

Minified Atom feed, formatted with 2 spaces
Input
<feed xmlns="http://www.w3.org/2005/Atom"><title>Release notes</title><entry><title>v2.1.0</title><link href="https://example.com/releases/2.1.0"/><updated>2026-10-22T13:30:38Z</updated></entry></feed>
Output
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Release notes</title>
  <entry>
    <title>v2.1.0</title>
    <link href="https://example.com/releases/2.1.0"/>
    <updated>2026-10-22T13:30:38Z</updated>
  </entry>
</feed>
A mismatched closing tag
Input
<order id="1042">
  <customer>Ada</customer>
  <note>Leave at <b>the back door</i></note>
</order>
Output
Line 3, column 34
Expected </b> but found </i>
<b> was opened on line 3, column 18. No <i> is open: check the spelling (names are case-sensitive) or remove </i>.

The fix is to change </i> to </b>. The tip says where <b> started, so you can see which of the two tags is wrong.

Minify, keeping text and preserved spaces
Input
<article>
  <title>Release notes</title>
  <p>Builds are <em>faster</em> now.</p>
  <code xml:space="preserve">npm  run  build</code>
</article>
Output
<article><title>Release notes</title><p>Builds are <em>faster</em> now.</p><code xml:space="preserve">npm  run  build</code></article>

Only the indentation between tags is removed. The text in <p>, including the spaces around <em>, and the double spaces inside xml:space="preserve" are kept.

Common errors and fixes

Expected </b> but found </a>
Tags are closed in the wrong order, a closing tag is misspelled (names are case-sensitive), or an HTML habit such as <br> has no closing tag. The tip gives the line and column where the open tag started. Close the inner element first, or write empty elements as <br/>.
Unclosed element <item>: the document ends before </item>
The document stops before the element is closed, often because a file or API response was cut off. DevPrix points to the start tag that was never closed: add the missing end tag or get the complete document.
Unescaped '&': write it as &amp;
A literal & in text or an attribute value, very often in a URL: ?a=1&b=2 must be written ?a=1&amp;b=2. Escape it, or wrap a block of text in <![CDATA[ … ]]>.
Undefined entity &nbsp;
XML predefines only &lt;, &gt;, &amp;, &quot; and &apos;. HTML entities such as &nbsp; and &copy; need a numeric reference (&#160;, &#169;) or a declaration in the DOCTYPE.
Namespace prefix 'dc' is not declared
A prefixed element or attribute such as dc:creator needs xmlns:dc="…" on that element or an ancestor. This usually happens when a fragment is copied out of a larger document: copy the declaration from the original root element.
Only one root element is allowed, but found a second: <user>
An XML document has exactly one top-level element. Wrap the repeated elements in a parent, for example <users>…</users>.
The XML declaration must be at the very start of the document
Nothing, not even a blank line or a space, may come before <?xml … ?>, and a document can have only one. Delete the leading whitespace, or the extra declarations left behind when files were joined.

Common use cases

  • Reading minified SOAP responses, sitemaps and RSS or Atom feeds
  • Finding the broken line in a pom.xml, Android layout or .csproj file
  • Checking hand-edited XML configuration before a deploy
  • Minifying XML for a request body or a test fixture
  • Exploring large SVG, KML or GPX files as a collapsible tree

Privacy and security notes

  • Your XML is checked and formatted by JavaScript in this browser tab. It is not sent to DevPrix or stored on a server.
  • Nothing a document points to is fetched: external DTDs, entities declared with SYSTEM or PUBLIC, schema locations and namespace URIs are treated as plain text, and entities are never expanded. A hostile document cannot make the page load files or URLs, the XXE problem some server-side parsers have.
  • Share copies a link that carries your input after the # in the URL. Browsers do not send that part to servers, but anyone you give the link to can read it, so do not share links that contain credentials or personal data.

Frequently asked questions

Does it validate against a DTD or an XML Schema (XSD)?

No. It checks that the document is well-formed XML 1.0 with correct namespaces, which every XML parser requires. Checking elements and attributes against a DTD or XSD (required fields, types, allowed values) needs a validating parser such as xmllint or one in your build. Entities declared in the DOCTYPE's internal subset are recognised. External DTDs are never fetched, so when a DOCTYPE points to one, references to entities it might declare are accepted.

What is the difference between XML and HTML?

HTML is forgiving and XML is not. In XML every element must be closed (<br/>, not <br>), attribute values need quotes, names are case-sensitive, & must be escaped, and only five named entities exist. That is why most HTML pages are not well-formed XML, while XHTML and SVG are.

How are namespaces checked?

Every prefix used on an element or attribute, such as dc: in dc:creator, must be declared with xmlns:dc="…" on that element or an ancestor; the xml: prefix is predeclared. The checker also rejects a prefix bound to an empty URI (xmlns:p=""), misuse of the reserved xml and xmlns prefixes, and two attributes whose prefixes point to the same namespace with the same local name. Namespace URIs are identifiers: they are compared as text and never fetched.

Are CDATA sections and comments kept when formatting?

Yes. Comments, CDATA sections, processing instructions and the DOCTYPE are copied exactly as written. An element that contains a CDATA section or any text is copied with its content unchanged, so CDATA blocks are never reindented.

Does the encoding declaration matter here?

The encoding="…" in <?xml … ?> tells a parser how to decode a file's bytes. Here the text is already decoded: pasted text comes from your clipboard and opened files are read as UTF-8, so the declaration is kept in the output but not used. If accented characters look garbled after opening a file, the file is probably not UTF-8; convert it and update the declaration to match.