XML Formatter

Pretty-print, minify, validate, and convert XML — entirely in your browser.

Output

      
Ctrl+Shift+F Format   Ctrl+Shift+M Minify   Ctrl+Shift+V Validate (may conflict with browser shortcuts)

Runs entirely in your browser — your XML never leaves the page.

How to Format XML Online

This free XML formatter runs entirely in your browser. Paste your XML into the left pane and click one of the action buttons to transform it instantly:

After transformation, use Copy to copy the output to your clipboard, or Download to save it as a file.

Understanding XML Well-Formedness

Valid XML must follow strict rules that distinguish it from the more lenient HTML. The most common mistakes that break XML well-formedness:

CDATA Sections

CDATA (Character Data) sections let you include raw text that would otherwise be interpreted as markup. Content inside <![CDATA[...]]> is preserved exactly as written, including literal < and > characters:

<description><![CDATA[Price: <$10 & free shipping]]></description>

This formatter preserves CDATA sections during both formatting and minification — the content between the brackets is never modified or reescaped.

XML vs HTML — Key Differences

HTML and XML look similar but have important differences that trip up developers. HTML is a specific application designed for web pages; XML is a generic, extensible data format:

XML to JSON Conversion

This tool uses the Badgerfish convention for XML↔JSON conversion, which provides a predictable round-trip for most XML structures:

Example — this XML:

<user id="42">
  <name>Alice</name>
  <email>alice@example.com</email>
</user>

Becomes this JSON:

{
  "user": {
    "@id": "42",
    "name": "Alice",
    "email": "alice@example.com"
  }
}

Common XML Use Cases for Developers

XML powers many systems you interact with daily. Knowing when you're dealing with XML (and how to format it) is a practical skill:

Frequently Asked Questions

Is this XML formatter free?
Yes, completely free. No account required, no rate limits, no sign-up.
Does my XML data leave my browser?
No. All processing happens entirely in your browser using JavaScript. Your XML data never reaches any server and is never stored or logged anywhere.
What is the difference between Format and Minify?
Formatting (pretty-printing) adds indentation and line breaks to make XML human-readable. Minifying removes all unnecessary whitespace to reduce file size — useful before saving to disk or sending over a network connection.
Can this tool validate XML against an XSD schema?
This tool validates well-formedness — checking that your XML follows the basic XML syntax rules defined by the W3C. Full schema validation (XSD, DTD, RELAX NG) requires server-side processing or a specialized library. Well-formedness validation catches the most common errors: unclosed tags, unquoted attributes, illegal characters, and missing root elements.
How does the XML to JSON conversion work?
Element names become JSON keys. Attributes are prefixed with @. For simple elements containing only text, the text becomes the value directly. When the same tag name repeats as siblings, they are collected into a JSON array. This follows the Badgerfish convention. Note: mixed content (text interleaved with child elements, like <p>foo<em>bar</em>baz</p>) is approximated — text fragments are concatenated into a single #text field, which means the original text–element positioning is not preserved when converting back to XML.
What size XML files can I format?
Since all processing runs in your browser, limits depend on your device's available memory. In practice, files up to several megabytes format in milliseconds. Very large files (50MB+) may cause slowdowns depending on your device and browser.