Pretty-print or minify XML, and check that it's well-formed — with exact line/column error locations and a few extra checks beyond basic parsing. Runs entirely in your browser.
About this tool
This tool does three things with the XML you give it: reformats it with consistent indentation, minifies it by stripping insignificant whitespace, and checks whether it's well-formed — all in the same pass, since a formatter has to fully parse a document before it can safely rewrite it. All processing happens locally in your browser using the built-in XML parser; nothing you paste or upload is sent to a server.
"Well-formed" is a specific, checkable property: every tag is closed, elements are properly nested, attribute values are quoted, and there's exactly one root element. It's a weaker claim than "valid against a schema" — a document can be perfectly well-formed XML while still violating the rules of a particular XSD. If you need to check a document against a schema, use the XML ↔ XSD tool instead; this formatter only checks well-formedness, plus a couple of extra, non-fatal checks described below.
What the formatter preserves
Reformatting XML safely means knowing which whitespace is structural (safe to rewrite) and which is part of the actual content (not safe to touch). This tool handles the cases that trip up naive formatters:
- Mixed content — an element containing both text and child elements (like
<p>Hello <b>world</b></p>) is left inline rather than having indentation inserted into it, since that would change what the text actually says.
xml:space="preserve" — content inside an element carrying this attribute is reproduced exactly as written, including all original whitespace and line breaks.
- CDATA sections, comments, and processing instructions — kept intact and in place, not reflowed or escaped.
- The XML declaration — if your input has one (
<?xml version="1.0" encoding="UTF-8"?>), it's kept as-is at the top of the output. If your input doesn't have one, this tool won't invent one.
Whitespace-only text sitting between element tags — the kind that exists purely for human readability in the source — is what actually gets rewritten when you change indent style or switch to Minify.
What "Validate" actually checks
Every parse attempt is a validity check: if the browser's parser can't build a document from your input, you'll see exactly where it gave up, down to the line and column. Beyond that hard check, this tool flags one additional non-fatal issue: an id attribute value reused on more than one element in the document, which is usually a mistake even though it doesn't make the XML malformed. This is a lightweight, best-effort check, not a substitute for schema or DTD validation.
Frequently asked questions
Does this validate against an XSD or DTD?
No — it checks well-formedness only (correct tag nesting, closing, quoting, and a single root element), plus a non-fatal duplicate-ID check. For schema validation, generate an XSD with the XML ↔ XSD tool and validate against it with a dedicated XSD validator.
Why does my formatted output not add newlines inside a certain element?
That element likely has mixed content — text sitting directly alongside child elements — or an xml:space="preserve" attribute. In both cases the formatter deliberately avoids inserting whitespace that could change the meaning of the content.
Will minifying lose any data?
No structural or textual data is removed — only whitespace-only text nodes between tags, which exist purely for human readability and aren't part of the document's actual content (except inside elements marked xml:space="preserve", where all whitespace is kept exactly as-is).
What happens to comments and processing instructions?
They're preserved in both Format and Minify modes, in their original position in the document.
Does it add an XML declaration if my file doesn't have one?
No. If your input doesn't start with an <?xml ... ?> declaration, the output won't have one either — this tool doesn't invent declarations or encoding claims your file didn't make.
Can it handle XML namespaces?
Yes. Namespace declarations and prefixed elements and attributes are parsed and reformatted correctly. Note that an undeclared namespace prefix is actually a well-formedness error in modern browser XML parsers, so it will show up as a parse error rather than a separate warning.
Why does the error line/column not exactly match what I see in my editor?
The position comes from the browser's own XML parser and refers to the text as parsed, not to any particular editor's line numbering (for example, if your editor uses different line-ending conventions). It's a strong pointer to the right area, not necessarily the exact character in every editor.
Is there a keyboard shortcut?
The output updates live as you type or paste, so there's no separate "run" step needed. Standard clipboard shortcuts work normally in both panes.
Does my file get uploaded anywhere?
No. Reading, parsing, formatting, and validating all happen locally in your browser, including files you upload or drag in. Nothing is sent to a server.
Is there a file size limit?
There's no hard limit enforced by the tool, but very large files take longer to process since your browser has to parse and rebuild the entire document tree in memory, and extremely large files may be slow on lower-powered devices.