XML Formatter & Validator

Paste XML — get it indented, minified, or validated live, with errors reported at their real line and column, not "somewhere in your document." Browse the structure as a collapsible tree, count elements, convert JSON ↔ XML with the lossy parts spelled out, and escape entities. All in your browser; nothing is uploaded.

Well-formed in one line: every open tag closed, tags properly nested, one root element, attributes quoted, and & < escaped in text — <a><b>text</b></a> ✓  ·  <a><b></a></b> ✗ That's well-formedness. Validity — matching a schema — is a separate, stricter test.

Parsing, formatting, and conversion run in your browser — documents are never uploaded, and the page works offline once loaded. The validator checks well-formedness; validating against an XSD schema requires schema-aware tooling and is out of scope here (said plainly rather than pretended).

Tree view & element counts

The same document as a collapsible structure — the fastest way to understand an unfamiliar payload — plus a tag tally, which answers "how many <item> elements are in here?" without writing any XPath.

Paste XML above to see its structure.
[ Ad slot — replace with AdSense / Ezoic code ]

JSON ↔ XML conversion

Convert either direction — with the caveat stated up front: the two models don't align perfectly, so conversion is lossy at the edges. XML attributes have no JSON equivalent (they become "@name" keys here); JSON has no notion of mixed text-and-element content (it becomes "#text"); and a single child element can't be distinguished from an array of one without a schema. Round-tripping ordinary data works; round-tripping document-style XML won't be byte-identical.

Escape / unescape XML entities

The five characters XML reserves — & < > " ' — escaped for safe embedding in text or attributes, or unescaped back (numeric references like &#169; included).

Formatting XSD schema files

An .xsd schema is XML like any other document, and machine-generated schemas — exported from a designer tool or a code-first framework — routinely arrive as a single unreadable line. Paste one here and it indents like anything else, with the xs:-prefixed structure (xs:element, xs:complexType, xs:sequence) laid out by nesting depth, which is exactly the shape you need to actually read a schema. The attribute-wrapping toggle earns its keep on schemas in particular, since xs:element declarations stack up name, type, minOccurs, and maxOccurs on every line. One boundary to be clear about: formatting a schema is not the same as validating a document against that schema — the latter needs schema-aware tooling and no honest browser page should claim otherwise.

SOAP envelopes and WSDL files

SOAP responses are the classic "wall of XML" — an Envelope, a Body, three namespace prefixes, and your actual data buried four levels deep, usually delivered minified. Formatting one here makes the nesting visible, and the tree view is often faster still: collapse the envelope plumbing and expand only the payload. WSDL service definitions get the same treatment; the element counts table gives a quick census of operation and message elements. Namespaces are preserved exactly as written — prefixes are not rewritten, expanded, or "normalized," because changing them changes what the document means to a namespace-aware consumer.

Common XML errors, decoded

ErrorWhat actually happenedFix
Mismatched closing tagTags closed in the wrong order — <a><b></a></b>. XML requires strict nesting; HTML's forgiveness doesn't apply.Close the inner element before the outer. The validator names both tags and the line.
Unescaped &A raw ampersand in text — common in URLs (?a=1&b=2) pasted into XML. & must start an entity.Write &amp;, or wrap the run in CDATA. The escape module above does it.
Unquoted attribute<a href=x> — legal in HTML, never in XML. Attribute values require quotes.Quote it: href="x".
Multiple root elementsTwo top-level elements — often a log file of concatenated XML fragments.Wrap the fragments in a single container element.
Duplicate attributeThe same attribute name twice on one element — usually a copy-paste artifact.Remove one; the validator points at the element.

Frequently asked questions

What's the difference between "well-formed" and "valid"?

Well-formed means the document obeys XML's syntax rules: proper nesting, quoted attributes, escaped special characters, one root. Every XML parser on earth requires it, and it's what this page checks. Valid means well-formed and conforming to a specific schema (XSD, DTD, RELAX NG) — right elements, right order, right types. Validation requires the schema and a schema processor; a document can be perfectly well-formed and wildly invalid against its schema, and vice versa is impossible.

Does the encoding declaration matter?

The <?xml version="1.0" encoding="…"?> declaration tells parsers how the bytes of the file are encoded. By the time text reaches this page it's already been decoded by your browser or editor, so the declaration is preserved as-is but can't be verified against the original bytes here. Practical advice: use UTF-8, declare UTF-8, and the declaration becomes a formality — mismatches between declared and actual encoding are a file-level problem to fix at the source.

How large a file can this handle?

Formatting and validation are tested smooth to around 5 MB of XML in a typical browser, and degrade gracefully rather than crash beyond that — the practical ceiling is your machine's memory and patience, since everything happens in the tab. The tree view caps itself at 3,000 nodes (with a note when it truncates) because a hundred-thousand-node DOM of <details> elements helps nobody. For files well beyond that, command-line tooling is the honest recommendation.

Is my XML uploaded anywhere?

No. The parser is JavaScript written into this page — no server call, no CDN library, and the page works offline once loaded. SOAP payloads and config files tend to contain internal hostnames and IDs; that's exactly why this runs where your data already is.

[ Ad slot — replace with AdSense / Ezoic code ]

Related tools