How to validate and format XML
Put XML in Input XML or choose Upload and select a file. XML Validator & Formatter trims the text, parses it as XML, and places the formatted or minified result in Output XML. You can then inspect the document in Tree View, copy the output, or download it.
- Enter XML in Input XML, or select Upload and choose a file.
- Open Validate & Format to view the parsed document and output.
- Under Indent, choose 2 spaces, 4 spaces, or Tab.
- Enable Minify output when you want compact output.
- Read the status message, then select Copy or Download when the buttons are enabled.
What XML Validator & Formatter checks
XML Validator & Formatter trims the text and passes it to the browser's XML parser. A successful parse sets the status to "Valid XML formatted successfully." A parse error sets "Invalid XML: check the input syntax." The check covers XML well-formedness. The page has no DTD or XSD control, so it does not check either schema.
Typing in Input XML or changing Indent or Minify output runs the parser again. The page parses the XML in the browser, and Download builds a file with a local Blob. Its code contains no fetch, XMLHttpRequest, sendBeacon, or form post that sends the XML to a server.
How Indent and Minify output change XML
Indent controls the whitespace inserted between XML tags. With Indent set to 2 spaces and Minify output turned off, the sample becomes:
<root>
<item>Example</item>
</root>
Select 4 spaces or Tab to change the indentation unit. Minify output removes whitespace between tags and returns the compact form after parsing and serialization.
How Tree View displays XML
After valid XML parses, select Tree View. It shows elements as branches and lists attributes, non-whitespace text, CDATA sections, comments, and processing instructions when they are present. The root branch starts open; deeper expandable branches start closed. Use the branch controls to change them.
What happens with empty or invalid XML
Blank or whitespace-only input hides the options and result sections, clears Output XML, and shows "Enter XML to validate and format." Invalid XML clears the output, disables Copy and Download, and leaves Tree View unavailable. Formatting changes whitespace around tags; it does not repair malformed XML or check DTD, XSD, or application-specific rules.
Where this comes up
- A compact XML snippet needs indentation before you inspect nested elements. Set Indent, then use Copy for the formatted result.
- Upload an XML document, read the status message, and open Tree View to inspect attributes and nested elements.
- After reviewing readable output, select Minify output and Download to save the compact result.
When to use XML Validate Tools
Use XML Validate Tools to compare XML validation pages. Choose XML Validator & Formatter when you need a well-formedness check plus formatted, minified, copied, downloaded, or tree-view output. This page has no DTD, XSD, or application-rule control, so it cannot check those rules.
Frequently asked questions
How do I validate and format XML?
Enter XML in Input XML or select Upload, then review the result under Validate & Format. The page validates and formats again when the input or formatting settings change.
Does XML Validator & Formatter validate DTD or XSD rules?
It checks if the input is well-formed XML. The page has no DTD or XSD selection or input control.
What does Minify output do to XML?
Minify output removes whitespace between tags and writes the parsed XML in compact form. Turn it off when you want the selected Indent setting in Output XML.
Can I inspect XML as a tree?
Yes, select Tree View after valid XML is parsed. The view shows nested elements and available attributes, text, CDATA, comments, and processing instructions.