XML Formatter & Validator
Check XML is well-formed, then format or minify it
Formatted XML appears here as you type
Checks well-formedness (XML 1.0 and namespaces), not DTD or schema validity. Only indentation between tags is changed: text, entities, CDATA, comments and inline whitespace are kept exactly, and mixed content and xml:space="preserve" blocks are not reflowed. Everything runs locally in your browser.
About XML Formatter & Validator
Check that an XML document is well-formed, then pretty-print it with consistent indentation or minify it to a single line. Errors are reported with the exact line and column and a plain explanation: a mismatched closing tag names the tag that is still open and where it started. The checker covers XML 1.0 and Namespaces in XML: the XML declaration and DOCTYPE syntax, tag nesting, attribute syntax and duplicates (including two prefixes for the same namespace), entity and character references, illegal characters, comment and CDATA rules, a single root element, qualified names, reserved namespace bindings, and undeclared prefixes. Formatting keeps your text, entity references, CDATA sections and comments exactly as written, and never reflows mixed content or elements marked xml:space="preserve". Everything runs locally in your browser.
How to Use XML Formatter & Validator
- Paste or type XML into the input.
- Read the status line: it either confirms the document is well-formed or points to the first error by line and column.
- Choose Format and an indent, or Minify to strip the whitespace between tags.
- Copy the result, or use it as the new input.
XML Formatter & Validator FAQ
Does this validate against a DTD or XML Schema?
No. It checks well-formedness: whether the document is correct XML that any parser will accept. Validity against a DTD or XSD is a separate, stricter check that needs the schema.
Will formatting change my data?
Formatting only replaces indentation: whitespace containing a line break between tags in element-only content. Text, attribute values, entity references, CDATA and comments are copied exactly. Whitespace without a line break, such as the space in <b>Hello</b> <b>world</b>, is treated as content, and elements with only text or whitespace inside, elements that mix text and child elements, and anything under xml:space="preserve" are left untouched.
Why is reported as an undefined entity?
XML predefines only five entities: &, <, >, " and '. Others, such as HTML's , must be declared in a DTD. Use a character reference like   instead, or declare the entity. Documents with an external DTD are not flagged, because the entity may be defined there.
Why does an undeclared prefix count as an error?
A name like soap:Envelope only makes sense when xmlns:soap is declared on that element or an ancestor. Namespace-aware parsers, which is nearly all of them, reject the document otherwise.
Is my XML uploaded anywhere?
No. Parsing and formatting run entirely in your browser, and nothing you paste is sent to a server.
Related tools
- JSON Formatter & ValidatorFormat, validate, and minify JSON
- YAML to JSON ConverterJSON ↔ YAML with YAML validation
- CSV to JSON ConverterConvert delimited text and JSON arrays
- Number Base ConverterBinary, octal, decimal, hex
- Color ConverterHEX, RGB, HSL, OKLCH with palette
- UUID GeneratorGenerate UUIDs with formatting options