XML Formatter & Validator
Format, minify, and validate XML in your browser. Runs locally.
Formatted XML will appear here.What is XML formatting?
XML formatting rewrites a document with consistent indentation and line breaks.
What is XML validation?
Well-formedness checking - matching tags, quoted attributes, one root element.
Formatter & Validator vs XML Validator
This combined tool handles both transformation and correctness checking: it can format or minify XML and can also report whether the document is well-formed. Odelvo's separate XML Validator is focused on validation and error diagnosis rather than producing formatted output.
Common XML errors
- Unclosed tag - an opening tag with no matching closing tag.
- Mismatched tag - a closing tag that doesn't match the most recent opening tag.
- Unquoted attribute - an attribute value missing its surrounding quotes.
- Unescaped ampersand - a raw & in text content instead of the & entity.
- Multiple root elements - content after the first top-level element closes.
A practical formatting example
A minified document like one long line of nested tags and attributes becomes, after formatting, a version with one element per line and each nesting level indented consistently, making it possible to scan the structure at a glance instead of scrolling sideways through a single line.
Namespaces, CDATA, and entity escaping
Namespace declarations (xmlns attributes) and prefixes are preserved as-is during formatting. CDATA sections keep their raw contents untouched, since reformatting the text inside them could change its meaning. Special characters in ordinary text content - ampersands, angle brackets, and quotes - must use their entity equivalents to be well-formed; the validator reports these as errors rather than silently escaping them.
Browser-based limitations
Because parsing happens with the browser's native XML parser, this tool checks well-formedness only - it does not validate against an external DTD or XSD schema, and it won't fetch external entities or DOCTYPE references over the network. Very large documents are also limited by available browser memory rather than a server-side processing limit.
Frequently asked questions
- Is my XML uploaded to a server?
- No. Parsing, formatting, and validation run entirely in your browser.
- Difference between well-formed and valid XML?
- Well-formed means syntax is correct: tags close, attributes are quoted, and there's one root element. Valid means it also conforms to a separate schema, such as a DTD or XSD. This tool checks well-formedness; it does not check against a schema.
- How does formatting handle CDATA sections?
- Content inside a CDATA section is left untouched, since it may contain characters like less-than signs that would otherwise need escaping; only the surrounding structure is reindented.
- Do I need to escape special characters myself?
- Characters like an ampersand or a less-than sign inside text content need to be escaped as entities such as & and < before the document is well-formed. The validator will flag an unescaped character with a parse error rather than fixing it automatically.
- Why does the error position differ between browsers?
- Formatting and validation use the browser's built-in XML parser, and different browsers report the line or column of a parse error slightly differently. The error message itself should still point you to the same underlying problem.