DevTools Logo

XML Formatter & Validator

XML Formatter & Validator

Format, validate, and analyze XML documents with comprehensive options

Input & Settings

2 spaces

XML Examples & Use Cases

Simple Structure

Basic XML with elements and text content.

<person>\n  <name>John Doe</name>\n  <age>30</age>\n  <active>true</active>\n</person>

With Attributes

XML elements with attributes for metadata.

<book id="123" category="fiction">\n  <title lang="en">Sample Book</title>\n  <author nationality="US">John Author</author>\n</book>

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.

Examples

Basic XML Formatting

<!-- 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>

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

XML Validation

<!-- 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

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

XML with Namespaces

<!-- 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>

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

    About this tool

    Format, beautify and validate XML documents online. Free XML formatter with syntax validation and detailed error reporting — no signup. XML Formatter & Validator runs in the browser on DevTools. There is no signup, and your input stays on this device unless the tool explicitly performs a live network lookup.

    What this tool does not do

    • XML Formatter & Validator is a free in-browser utility, not a hosted API. It does not keep server-side history and is not a substitute for production verification in your own stack.

    How do I use this tool?

    1. How do I use XML Formatter & Validator?

      Open XML Formatter & Validator, enter or paste your input, and copy the result. The page works without an account.