Developer Tools
XML Formatter & Validator
Validate and format XML locally in your browser.
Validate and pretty-print XML locally in your browser. The parser checks well-formed XML syntax; it does not validate against an XSD or DTD schema.
XML parsing is available after this tool loads in your browser.
About This Tool
XML is easy for software to exchange but compact or inconsistently indented documents can be difficult for people to inspect. This tool parses XML with the browser's XML parser, reports malformed markup, and produces readable indentation for well-formed documents without sending the pasted content to a server.
How To Use It
- Paste or type an XML document into the input area.
- Choose two- or four-space indentation for the readable output.
- If the document is well formed, inspect the formatted result and copy either the readable or compact serialization.
- If validation fails, use the parser message as a starting point and check matching tags, quoted attributes, entities, and document structure.
Examples
Format an API payload
Turn compact XML such as <response><status>ok</status><count>2</count></response> into indented output that is easier to review.
Find a mismatched closing tag
Input such as <root><item></root> is not well formed because item is never closed. The validator reports a parser error instead of silently rewriting it.
Inspect attributes and escaped text
XML attributes remain attached to their elements, while entity-escaped text such as & is parsed and serialized safely.
Useful Notes
What validation means
Validation here means well-formed XML syntax: one document element, correctly nested tags, valid attribute syntax, and parseable entities. It is not schema validation.
Formatting behavior
Pretty printing adds indentation and line breaks around element structure. Text-only elements stay compact where practical. The output is a serialization of the parsed XML rather than a byte-for-byte preservation of the source.
XSD and DTD scope
This tool does not check whether elements, attributes, types, or ordering satisfy an XSD, DTD, or application-specific contract. A document can be well formed and still be invalid for a particular schema.
Whitespace caution
Whitespace can be meaningful in some XML applications, especially mixed-content documents where text and child elements are interleaved. Review formatted output before replacing source files whose exact whitespace semantics matter.
Namespaces
The browser XML parser understands namespace declarations and prefixed names. Formatting does not attempt to rename, resolve, or simplify namespaces.
Local processing
Parsing and formatting run with browser APIs on the page. This tool does not require an upload or external formatting service.
FAQ
Is my XML uploaded?
No. This formatter uses browser XML APIs and processes the text on the page.
Does this validate XML against XSD?
No. It checks whether XML is well formed, not whether it conforms to a schema.
Why can formatting change the exact source text?
Parsing converts source markup into an XML document model and then serializes it again. Quote style, empty-element syntax, entity representation, and whitespace can therefore differ while representing the same parsed structure.
Can I use this for XML with namespaces?
Yes for syntax formatting and well-formedness checks. The tool does not perform namespace-aware schema validation.
What causes common XML parse errors?
Typical causes include mismatched tags, unquoted attributes, multiple root elements, invalid entities, and special characters such as an unescaped ampersand.
Related Tools
JSON Formatter & Validator
PopularValidate JSON, pretty-print it, minify it, and inspect JSON paths.
HTML Entity Encoder / Decoder
Convert text to and from HTML entities directly in your browser.
Text Difference Checker
Compare two texts and find line-by-line changes.
UTF-8 Byte Counter
Count UTF-8 bytes, Unicode code points, and UTF-16 code units.