Skip to content

XML formatter

Validate and pretty-print inert XML without loading external entities or resources.

XML format85 characters
Paste configuration text. The live preview stays inert and is limited for responsiveness.
Formatted XML previewReady
<?xml version="1.0" encoding="UTF-8"?>
<catalog version="1">
  <book id="ada">Ada</book>
  <book id="grace">Grace</book>
</catalog>
Processed on your device

How it works & useful details

Safe XML formatting

XML is parsed as inert local data and written with two-space indentation. Attributes and element/text content are kept. Comments are removed and CDATA sections are written as equivalent escaped text. Formatting does not load schemas, follow links, or request external resources.

DTD and entity declarations are rejected before parsing to avoid external/entity expansion behavior. Mixed text-and-element content stays compact to preserve its order.

Private, bounded processing

This workspace parses text only in your browser. It never opens links, requests external entities, runs pasted configuration, or saves your document. Input is limited to 500,000 characters; conversion output is limited to 1,000,000 characters.

About this tool

XML formatter validates and pretty-prints inert XML, making deeply nested documents readable. It is useful for inspecting exported configuration, sitemaps, and data exports before editing them by hand.

The document is parsed as text without loading external entities or resolving remote resources, which avoids the XXE class of problems associated with careless XML tooling. Mismatched tags are reported with their position.

How to use it

  1. Paste the XML document.
  2. Run the formatter to validate structure and produce indented output.
  3. Fix any reported mismatches or malformed markup.
  4. Copy or download the formatted XML.

Worked example

<catalog version="1"><book id="ada">Ada</book><book id="grace">Grace</book></catalog>

is formatted as

<?xml version="1.0" encoding="UTF-8"?>
<catalog version="1">
  <book id="ada">Ada</book>
  <book id="grace">Grace</book>
</catalog>

Formatting also checks well-formedness: every start tag must be closed in the right order, attribute values must be quoted, and there must be exactly one root element. A malformed document is reported instead of being reformatted.

Safe by design

XML parsers that process DTDs and entities can be tricked into reading local files or contacting internal servers (XXE attacks), or into expanding a few bytes into gigabytes (the "billion laughs" attack). This formatter rejects DOCTYPE and entity declarations before parsing and never loads schemas or external resources. That makes it safe to paste untrusted XML such as sitemap files, data exports, and simple feeds. A default xmlns attribute is fine, but prefixed names such as soap:Envelope or atom:link are not supported yet, so SOAP and SAML documents are rejected.

Mixed content, where text and elements are interleaved as in <p>Hello <b>world</b></p>, is kept on one line. Adding indentation there would change the text itself. Comments are removed, and CDATA sections are written as equivalent escaped text, so <![CDATA[x<y]]> becomes x&lt;y.

Frequently asked questions

Are external entities or DTDs resolved?

No. External entities are not fetched or expanded, and doctypes are treated as text.

Does it change the document meaning?

Only whitespace between elements is adjusted for readability; element names, attributes, and text content are preserved.

What is the limit?

Up to 500,000 characters of XML text.

Does formatting change the data?

Element names, attributes, and text content keep their meaning. Whitespace between elements changes, comments are removed, and CDATA is rewritten as escaped text. Keep the original if comments matter.