XML formatter & validator

Validate and indent XML.

Enable JavaScript to use this interactive tool. Paste input, choose options, then copy or download the result, or save it to your notebook.

Example and common questions

Make an XML response easier to inspect while preserving meaningful mixed-content spacing. In this example, the words and inline strong element form one message. Formatting checks well-formedness; it does not validate against an XSD schema.

How to format an XML response

  1. Paste the XML response and choose two or four spaces for indentation.
  2. Run the formatter and review any well-formedness error before continuing.
  3. Inspect mixed-content regions, then copy, download, or save the formatted response.

Indent an API response while preserving mixed content

Indent spaces
2
Input
<response><status>ready</status><message>Hello <strong>Maya</strong>!</message></response>
Formatted XML
<response>
  <status>ready</status>
  <message>Hello <strong>Maya</strong>!</message>
</response>
What is validated?

The formatter checks XML well-formedness and namespace parsing. It does not validate a document against an XSD schema.

Why is some text not re-indented?

Mixed content and xml:space="preserve" regions retain their source text so indentation does not change meaningful spacing.

Are external entities fetched?

No. DOCTYPE declarations are rejected and external entities are not resolved or fetched.

Common errors and limitations

Check mismatched tags, malformed attributes and namespace declarations. Documents containing a DOCTYPE are rejected; remove it only if the remaining document is appropriate for your use.