What is this tool?
This XML formatter and validator pretty-prints, minifies and checks XML using your browser's built-in parser. Paste into the input pane, or open or drop an .xml, .svg, .xsl, .xsd or .wsdl file, and the output pane formats as you type. The formatter walks the parsed document node by node, so the <?xml?> declaration, DOCTYPE, comments, CDATA sections, processing instructions and mixed text are kept, and only the whitespace between elements changes. Minify removes that whitespace without touching text, attributes or CDATA. Choose an indent of 2 spaces, 4 spaces or a real tab, and whether empty elements are kept as written, collapsed to <a/> or expanded. If the XML is malformed, the tool shows the line and column and selects the line in the input. The Tree view copies the XPath of any element or attribute when you click it, and you can run XPath queries, convert XML to JSON, or see node statistics. Your XML is not uploaded.
How to Use
- Paste XML into the input pane, or press Open file or drop a file on it.
- Pick an Indent and how empty elements are written. The output formats as you type, or press Format (Ctrl+Enter). Press Minify for a compact version.
- Press Validate. If there is a problem, read the line and column in the output; the faulty line is selected in the input.
- Switch the output to Tree and click an element or attribute to copy its XPath, or open XPath query to evaluate an expression such as //item/@id.
- Press Copy or Download in the output pane, or XML β JSON to convert.
Frequently Asked Questions
Does Validate check my XML against an XSD or DTD?
No. It checks that the XML is well-formed, meaning tags match, attributes are quoted and there is a single root element. Schema validation is not performed.
Does formatting change my data?
No. Comments, CDATA sections, processing instructions, the XML declaration and text inside elements are written back as they were, and elements with mixed text and tags, or xml:space="preserve", are left on one line. Character references such as © are written as the character itself, which means the same thing.
Why does it say my XML is invalid?
Common causes are an unescaped & or <, a tag that is not closed, mismatched tag names, or more than one root element. The reported line and column point at or just after the problem.
How does XML to JSON handle attributes and repeated tags?
Attributes go under an _attributes key, and repeated sibling elements become an array. Elements that contain only text become plain strings; elements with both attributes and text keep the text under _text.
Other tools
There are more calculators, converters and editors on Wivrix. If something is missing, tell us.