XML Formatter & Validator

Format, validate, and analyze XML documents with comprehensive options, element/attribute counting, and detailed validation

Details

This tool helps you format and validate XML (Extensible Markup Language) documents. XML is widely used for storing and transporting data, especially in configuration files, web services (SOAP), and data exchange between systems. The formatter makes your XML human-readable with proper indentation, while the validator checks for well-formedness and can validate against XML schemas.

Usage Examples

Basic XML Formatting

Steps / Code:

<!-- Before formatting -->
<root><element attribute="value">Text</element><element>More text with <child>nested element</child></element></root>

<!-- After formatting -->
<root>
  <element attribute="value">Text</element>
  <element>
    More text with 
    <child>nested element</child>
  </element>
</root>

Explanation:

Transforms a compact, hard-to-read XML document into a properly indented format with clear hierarchical structure.

XML Validation

Steps / Code:

<!-- Invalid XML (Missing closing tag) -->
<person>
  <name>John Doe</name>
  <age>30</age>
  <email>john@example.com
</person>

<!-- Error Message -->
Error at line 5: Element 'email' is not closed

Explanation:

Validation detects common XML errors such as missing closing tags, invalid nesting, or malformed syntax.

XML with Namespaces

Steps / Code:

<!-- Before formatting -->
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"><soap:Header><auth xmlns="http://example.org/auth"><username>user</username><password>pass</password></auth></soap:Header><soap:Body><m:GetStockPrice xmlns:m="http://example.org/stock"><m:StockName>IBM</m:StockName></m:GetStockPrice></soap:Body></soap:Envelope>

<!-- After formatting -->
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/">
  <soap:Header>
    <auth xmlns="http://example.org/auth">
      <username>user</username>
      <password>pass</password>
    </auth>
  </soap:Header>
  <soap:Body>
    <m:GetStockPrice xmlns:m="http://example.org/stock">
      <m:StockName>IBM</m:StockName>
    </m:GetStockPrice>
  </soap:Body>
</soap:Envelope>

Explanation:

Formats complex XML with namespaces, common in SOAP web services and enterprise applications.