XML Formatter

Pretty-print, minify, and validate XML with syntax highlighting.

Tool Media & Files Updated Apr 19, 2026
How to Use
  1. Paste XML content into the input area.
  2. Pick the indent width (2, 4 spaces, or tab).
  3. Click Pretty to format with proper indentation, or Minify to strip whitespace.
  4. The browser's native XML parser validates as you go — errors show line and column.
  5. CDATA sections are preserved verbatim (their content is never reformatted).
  6. Copy the formatted output with the copy button.
Input
Output
Waiting
Paste XML.

Notes

Well-formed
Single root, closed tags
Namespaces
Preserved
CDATA
Not reformatted
Comments
<!-- … --> kept
Processing instr.
<?xml … ?> kept
Entities
Unchanged

Frequently Asked Questions

Will this format HTML?

Strict XML formatting will reject most HTML because HTML is not well-formed XML (unclosed tags, attributes without quotes, etc.). For HTML, use the dedicated HTML formatter or the Minifier/Beautifier with HTML mode. XHTML (XML-compliant HTML) works here.

What's the difference between XML and HTML?

<strong>XML</strong> requires every tag to be closed (or self-closing), every attribute quoted, case-sensitive tag names, and one root element. <strong>HTML</strong> is much more forgiving — many tags are optional, attributes can be unquoted, case-insensitive. XML is for data interchange (configuration, RSS, SOAP, SVG); HTML is for presentation.

How does CDATA work?

<code>&lt;![CDATA[ ... ]]&gt;</code> wraps content that should not be parsed as XML — useful for embedding code, scripts, or text that contains <code>&lt;</code> or <code>&amp;</code>. The formatter preserves CDATA blocks intact, since reformatting them might break embedded content. Common in RSS, Atom feeds, and legacy SOAP APIs.

What about XML namespaces?

Preserved correctly. Namespace declarations (xmlns:prefix='URI') and prefixed elements are kept intact. The formatter doesn't try to optimize namespace usage; if your input declares 5 namespaces and uses 2, the output keeps all 5 declarations.

Will it validate against a DTD or XSD?

No — it only checks well-formedness (proper nesting, closed tags, valid XML syntax). For schema validation against a DTD or XSD, use a dedicated validator like xmllint, an online schema validator, or a desktop tool with XSD support. Browser native XML parsers don't do schema validation.

Is XML still relevant?

For new development, JSON has largely replaced XML for web APIs and most config formats. XML persists in: SOAP web services (banking, healthcare, government APIs), RSS/Atom feeds, Microsoft Office documents (.docx is XML inside), Java configuration (.xml in many frameworks), SVG vector graphics, and legacy enterprise integration. Knowing XML formatting still matters.

Common Use Cases

SOAP API debugging

Format SOAP request and response payloads to understand what's being sent and received.

RSS / Atom feed inspection

Examine podcast or blog feeds for structure issues.

Configuration file editing

Format Spring, Maven (pom.xml), or other Java project files for readability.

Office document inspection

Unzip a .docx or .xlsx and format the embedded XML to understand the document structure.

SVG editing

SVG is XML — format hand-written or generated SVG for clean structure.

Sitemap audit

Format and validate XML sitemaps for SEO before submitting to search engines.

Last updated: