XML Formatter

Prettify, minify, and validate XML with CDATA-safe formatting

Indent:
Output will appear here…

About this tool

The XML Formatter prettifies, minifies, and structurally validates XML β€” the same category of tool as ToolNinja's JSON and HTML formatters, built for XML's specific quirks. CDATA sections (`<![CDATA[ ... ]]>`) are preserved exactly as written rather than reformatted, since their contents are explicitly meant to be treated as opaque, unparsed text. Before formatting, the tool also walks the tag structure and flags unclosed or mismatched tags with a specific error, rather than silently producing malformed output. XML still underpins a huge amount of real infrastructure β€” SOAP APIs, RSS/Atom feeds, Android layouts, Maven/Ant build files, SVG, configuration formats for countless enterprise systems β€” and a minified or inconsistently-indented XML payload is exactly as unreadable as minified JSON without a formatter.

When to use it

  • β†’Pretty-printing a minified SOAP request or response for debugging
  • β†’Formatting an RSS or Atom feed to inspect its structure
  • β†’Cleaning up an Android layout XML or Maven pom.xml copied from elsewhere
  • β†’Minifying XML before storing it in a database column or sending it over the wire
  • β†’Catching an unclosed or mismatched tag before it causes a confusing downstream parser error

Tips

  • β—†CDATA sections are left completely untouched during formatting β€” their content is meant to be opaque to the XML parser, and reformatting it would change its meaning.
  • β—†The structural validator catches unclosed and mismatched tags specifically β€” it's a syntax check, not a schema (XSD/DTD) validator, so it won't catch a tag that's well-formed but semantically wrong for a given format.
  • β—†Minify before storing XML in a database column or config value β€” it can meaningfully shrink payload size on high-volume systems still using XML for interchange.

Frequently asked questions

Does this validate XML against an XSD schema?

No β€” it performs structural validation (checking that every tag is properly opened and closed, correctly nested) rather than schema validation. A document can be well-formed XML and still violate a specific XSD or DTD schema; this tool only catches the former.

Why does my CDATA content stay as one long line instead of getting indented?

CDATA sections are designed to hold content β€” often HTML, code, or other markup β€” that should not be parsed or altered by the XML processor. Reformatting the whitespace inside a CDATA block would change what that content actually represents, so the formatter deliberately leaves it exactly as written.

Is my XML data uploaded anywhere?

No. Parsing, validation, and formatting all run in your browser via JavaScript. Your XML β€” which may contain sensitive API payloads or internal config β€” never leaves your device.

Related tools

πŸ₯· ToolNinja