XML Formatter & Validator
Paste XML to pretty-print it, minify it, or find out why it is not well-formed. Errors are reported with the line and column and an explanation. The checker is safe by design: it never loads external files or the network and never expands entities, so documents built to attack XML parsers are simply refused. Everything runs in your browser.
Result
- Root element
- Elements
- Attributes
- Nesting depth
- Text nodes
- Comments
- Namespace declarations
- Input size
- Output size
Examples
Common mistakes and what the checker says:
| XML | Problem |
|---|---|
<a><b></a> | The closing tag does not match the opening tag |
<a id=1/> | An attribute value without quotes |
<a>fish & chips</a> | A bare ampersand in text |
<a/><b/> | Two root elements |
Formula & Methodology
The XML is read once, from start to end, by a checker written for this site. It verifies names, nesting, attribute syntax, comments, CDATA, processing instructions and character references, then prints the same nodes again with indentation or without spacing. Text, attributes and entities are copied exactly as you wrote them.
Well-formed means the document follows XMLโs syntax rules. It does not mean it is valid against a schema or DTD, which this tool does not check.
Notes and limitations
- Safety: external entities, DTD files and network locations are never loaded, and entities are never expanded. A DOCTYPE that declares entities is refused, which blocks โbillion laughsโ and XXE-style documents.
- Pretty-printing adds whitespace only between elements. Text, mixed content (text next to elements) and CDATA are kept exactly, because whitespace inside them can matter.
- Namespaces are checked for name syntax only; prefixes are not resolved. DTD and schema validation (XSD) are not performed.
- Texts up to 5,000,000 characters and 512 levels of nesting are accepted.
- Only XML 1.0 well-formedness is checked. Documents in other encodings must be pasted as text.
How to Use
- Paste your XML into the box.
- Choose Format to pretty-print it (and the indentation) or Minify to remove spacing.
- If the XML is not well-formed, use the line, column and explanation to fix it.
- Check the statistics, then copy the result or download it as a .xml file.
Frequently Asked Questions
Is my XML uploaded?
No. It is checked and formatted in your browser and never sent to ToolQuarter, analytics or any other service. Nothing is fetched while it is processed.
Why was my document refused because of a DOCTYPE?
A DOCTYPE that declares entities can make parsers read local files, call a server or expand to gigabytes. This tool never processes entity declarations, so it refuses such documents. A DOCTYPE without entity declarations is accepted and kept as written.
What does โwell-formedโ mean?
It means the syntax is correct: one root element, tags properly nested and closed, quoted attribute values, valid names and escaped special characters. It does not mean the content follows a particular schema.
Why does formatting not indent some text?
To avoid changing your data, elements that contain text, or text mixed with other elements, are kept on one line exactly as written. Only elements that contain only other elements are indented.
Can it validate against an XSD or DTD?
No. This tool checks well-formedness only. Schema validation needs the schema and a full validating parser.
Last updated: