πŸ”’ All processing happens in your browser. No data is sent to any server.
FREE

XML Formatter & Validator

← All Tools

Input XML

Output

Output will appear here…

What is XML Formatter?

XML Formatter validates, indents, and prettifies XML documents. Paste any XML β€” RSS feeds, SOAP responses, SVG files, Android layouts, pom.xml build files, Sitemap XML, or raw API responses β€” and the formatter outputs well-indented XML with consistent spacing, sorted attributes (optional), and highlighted syntax errors with line numbers.

XML (Extensible Markup Language) is a hierarchical text format used for data interchange, configuration, and document formats. It remains the format for RSS/Atom feeds, SOAP web services, Android manifests and layouts, Maven/Gradle build files, SVG graphics, XHTML, Office Open XML (docx/xlsx), and many enterprise APIs that predate JSON.

Common XML problems this formatter catches: unclosed tags (most common XML error), mismatched tag names, invalid character references (& must be &), multiple root elements (XML requires a single root), and namespace prefix errors. The formatter also minifies XML (removes all whitespace) for production use where file size matters β€” RSS feeds and Sitemap XML are often served minified.

How to Use

  1. Paste your XML into the input field.
  2. Click Format to validate and indent the XML with 2-space indentation.
  3. Check the error panel for any validation errors β€” errors include the line number and description.
  4. Use 'Sort attributes' to alphabetically sort attributes within each element β€” helpful for consistent diffs.
  5. Use 'Minify' to remove all non-significant whitespace for production deployment.

Examples

RSS feed with irregular indentation

Result: Validates feed structure and reformats with consistent indentation β€” making enclosure, link, and description elements readable

Android layout XML

Result: Formats complex nested ConstraintLayout and LinearLayout hierarchies with 2-space indentation per nesting level

SOAP response with namespaces

Result: Handles namespace prefixes (soap:Envelope, xsi:type) and formats the body content while preserving namespace declarations

Frequently Asked Questions

What is the difference between XML and HTML?

HTML is designed for human-readable web documents and has loose parsing rules (unclosed tags are often accepted). XML is a strict data format β€” every opened tag must be closed, attribute values must be quoted, and there must be exactly one root element. XHTML is HTML written with XML's strict rules.

What causes 'entity not defined' errors in XML?

XML only predefines 5 entities: &amp; (&), &lt; (<), &gt; (>), &apos; ('), &quot; ("). Any other &name; reference (like &nbsp; from HTML) is invalid unless declared in a DTD. Replace unknown entities with their Unicode escape: &#160; for &nbsp;.

What is an XML namespace?

Namespaces prevent element name collisions when XML from multiple vocabularies is combined. A namespace is declared with xmlns:prefix='URI'. Elements and attributes with that prefix belong to that namespace: . The URI is just an identifier β€” it doesn't need to resolve to a real document.

How is XML different from JSON?

JSON is more compact, natively maps to JavaScript data structures, and lacks native support for comments, attributes, or mixed content. XML supports attributes, mixed content (text and child elements in the same node), XML namespaces, and has robust schema languages (XSD, RelaxNG). JSON has replaced XML for most new REST APIs; XML persists in legacy systems and document formats.

Can I convert XML to JSON?

Yes β€” use the 'Convert to JSON' button. Simple XML (elements with text content only) converts cleanly. Complex XML (with attributes, mixed content, or namespaces) requires choices about how attributes map to JSON keys (common convention: @attribute names). The conversion is lossy β€” round-tripping JSON back to the original XML may not be exact.

Related Tools