HomeToolsFormattingXML Formatter

XML Formatter

Pretty print, validate, and clean up your XML data with customizable indent options.

Formatting
Indent:
Input XML
Formatted XML

What is an XML Formatter?

An XML formatter is a developer utility that parses Extensible Markup Language (XML) documents, structures them with clear indentation, and validates them for syntax errors. It converts minified or poorly structured XML into a readable format while verifying tag hierarchy.

Features

  • Custom Indentation: Choose 2 spaces, 4 spaces, or Tab indentations.
  • Tag Validation: Automatically check if your XML tags are correctly matching and nested. Detects unclosed or mismatched tags instantly.
  • Empty Element Collapsing: Toggle option to collapse tags like <tag></tag> to self-closing <tag /> tags.
  • Comment Retention: Keep comments intact or clean them up from the output.
  • CDATA & Namespace Support: Safely formats tags with namespaces, CDATA structures, and XML declaration lines.

Example Input

<?xml version="1.0" encoding="UTF-8"?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>

Example Output

<?xml version="1.0" encoding="UTF-8"?>
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

Contribute

Find a bug or want to suggest an improvement to this tool?