XML Formatter
Validate, pretty-print or minify XML with real error messages.
About this formatter
Paste XML and it's validated as you type by the browser's own strict parser โ the same one that rejects malformed feeds and sitemaps in the wild โ with the actual error when something's broken. Pretty print indents two spaces and keeps single-value elements on one line; minify strips inter-tag whitespace for compact transport. Comments and CDATA survive both.
The errors XML actually throws
Ninety percent of broken XML is one of four things: an unescaped ampersand (every & in text must be & โ URLs with query strings are the classic carrier), mismatched or unclosed tags (XML has no HTML forgiveness โ every tag closes, exactly in nesting order), attribute values without quotes, or multiple root elements (a document gets exactly one). The parser here names the line, which beats staring. XML still runs more of the world than fashion suggests โ RSS and podcast feeds, sitemaps, SVG, invoicing standards, Android layouts, Office documents under the hood โ so a formatter that tells the truth about errors stays useful. JSON work belongs to the JSON formatter; converting between the two is deliberately not offered, because attributes-versus- elements makes any automatic mapping lossy in one direction.
Frequently asked questions
Why does my XML fail on an ampersand?
In XML, & always begins an entity โ a bare & in text or a URL is illegal. Write & instead (and < for <). It's the single most common XML error in the wild.
What does 'junk after document element' mean?
Content after the root element closed โ XML allows exactly one root. It usually means a missing wrapper element or a stray tag at the end.
Is this safe for large or sensitive XML files?
Yes on both counts: parsing happens in your browser with nothing uploaded, and the practical size limit is your device's memory, not a server quota.
Can I convert XML to JSON here?
Deliberately not โ XML's attributes, ordering and mixed content have no faithful JSON equivalent, so any automatic conversion silently loses structure. Format and validate here; restructure with intent in code.