Helper-KitCode Tools

XML Formatter

Format, minify and validate XML, and explore it as a tree. Errors show the exact line and column.

View:
Indent:
XML
Try an example:
Formatted XML

More:HTML MinifierJSON BeautifierHTML EntitiesRegex Tester

Your XML is checked with the browser's own XML parser, so errors show the exact line and column. The result is always valid XML: special characters are escaped, and comments, CDATA sections, processing instructions and the <?xml?> declaration are kept. Text is never changed: elements that contain text stay on one line, and xml:space="preserve" sections are left exactly as written. Everything runs in your browser.

About This Tool

Paste XML, open a .xml file or drop one in. Format mode indents the document with 2 spaces, 4 spaces or tabs. Minify mode removes the whitespace between elements to make it as small as possible. The result is checked so it is always valid XML. Text content is never changed: elements with text stay on one line exactly as written, and elements marked xml:space="preserve" keep their spacing. CDATA sections, processing instructions, the XML declaration and the DOCTYPE are kept. Comments can be kept or removed. If the XML is not well-formed, the error shows the line and column, and "Show in input" jumps to it. Tree view shows elements, attributes and text as a collapsible tree. Everything runs in your browser.

Common Use Cases

  • Reading RSS feeds, sitemaps and product feeds
  • Formatting SOAP requests and responses
  • Finding errors in XML configuration files
  • Minifying XML before sending or storing it
  • Exploring the structure of an unfamiliar XML document

Frequently Asked Questions

Will formatting change my data?

No. Element names, attributes and text are kept exactly. Only the whitespace between elements changes.

Are CDATA sections and comments kept?

CDATA sections are always kept. Comments are kept unless you turn off "Keep comments".

Why does it say my XML is invalid?

XML must be well-formed: every tag closed, attributes quoted, one root element and special characters such as & written as &amp;. The error shows where the first problem is.

Was this tool helpful?

More in this category