DevKits

XML Formatter & Validator

Format, beautify, and validate XML documents online. Handles namespaces, CDATA sections, and mixed content.

Last updated:

172 chars

Paste XML above to format, indent, and validate it instantly. Namespaces, CDATA, and comments are preserved; only whitespace is normalized. Everything runs in your browser.

What is XML Formatter?

An XML formatter takes minified or messy XML and re-indents it with consistent nesting so the structure is readable. It also validates well-formedness — flagging unclosed tags, mismatched elements, and malformed attributes. XML remains common in SOAP APIs, RSS/Atom feeds, SVG, Android layouts, Maven POMs, and countless config files, making a reliable formatter a daily need.

How to format XML online

  1. 1Paste your raw or minified XML into the input pane.
  2. 2The tool re-indents it and reports any well-formedness errors.
  3. 3Choose your indent size (2 spaces, 4 spaces, or tabs).
  4. 4Copy the formatted XML into your editor, feed, or config file.

Use Cases

Read SOAP / API responses

SOAP and legacy APIs return dense XML on one line. Format it to inspect the envelope and body.

Clean up config files

Re-indent a Maven pom.xml, Android layout, or web.config that lost its formatting.

Debug RSS/Atom feeds

Pretty-print a feed to verify item structure and spot malformed elements.

Code Examples

Minified input

<note><to>Ada</to><from>Grace</from></note>

Formatted output

<note>
  <to>Ada</to>
  <from>Grace</from>
</note>

Key Concepts

Well-formed vs valid
Well-formed means syntactically correct (tags nest and close). Valid means it also conforms to a DTD or XSD schema. This tool checks well-formedness.
CDATA
A <![CDATA[ ... ]]> section holds text that should not be parsed as markup — useful for embedding code or HTML. It's preserved verbatim.
Namespaces
Prefixes like xmlns:soap disambiguate element names from different vocabularies. Formatting keeps them intact.

Tips & Best Practices

  • Whitespace between elements is normalized, but whitespace inside text nodes may be significant — verify mixed content.
  • CDATA and comments are preserved exactly; only inter-element indentation changes.
  • If validation fails, the first mismatched or unclosed tag is usually the real culprit — start there.
  • For huge XML documents, a streaming parser (SAX) in code scales better than loading everything into memory.

Frequently Asked Questions

Does the formatter preserve CDATA and comments?

Yes. CDATA sections and comments are preserved verbatim; only whitespace between elements is normalized to match the selected indent.

What indent options are supported?

2 spaces, 4 spaces, or tab characters. The choice is applied consistently at every nesting level of the output.

Related Tools