Guide

THE TOOLBOX / DATA & MARKUP UTILITIES

Format XML, test XPath,
and convert to JSON.

Validate XML tag nesting, pretty-print or minify markup, evaluate XPath queries, and convert XML trees into structured JSON locally in your browser.

Ready. Paste XML to validate, format, convert to JSON, or run XPath queries.

Presets
OutputVALID · 12 lines · 334 B

THE DETAILS

W3C XML 1.0 validation, XPath expressions, and lossless JSON mapping.

1. Step-by-Step Workflow

Paste an XML document, RSS/Atom feed, SOAP envelope, or Maven pom.xml into the editor. Switch between Formatted XML, Minified XML, XML → JSON, and XPath tabs—or type an XPath query to filter matching nodes in real time.

2. W3C XML 1.0 Well-Formedness Checks

Under the W3C XML 1.0 (Fifth Edition) specification, every opening tag must match its closing tag in exact case, all attribute values must be quoted, and the document must have a single root element. The tag-stack validator pinpoints the exact mismatched or unclosed element name.

3. Deterministic XML → JSON Mapping

Converting XML to JSON requires disambiguating attributes from child elements. Attributes are mapped to @attribute keys, leaf text nodes become string values (or #text when combined with attributes), and repeated sibling tags automatically group into JSON arrays.

XPath Query Examples & CLI Matrix

XPath / XML TaskExpression / OutputCLI Equivalent
Filter by attribute//service[@env="production"]/name/text()xmllint --xpath '...' file.xml
Extract attribute values//service/@idxmlstarlet sel -t -v '//service/@id'
Pretty-print XML (2 spaces)Indented hierarchy with inline leaf textXMLLINT_INDENT=" " xmllint --format
Convert XML to JSON@attr + array groupingxq '.' file.xml

Common XML Pitfalls & Troubleshooting

Unescaped Ampersands (&) & Less-Than (<)

A raw & or < inside XML text content is a fatal syntax error. Escape them as &amp; and &lt; or wrap code blocks in <![CDATA[...]]>.

Case-Sensitive Tag Names

XML tags are strictly case-sensitive: opening <Service> and closing </service> will trigger a mismatched closing tag error.

Multiple Root Elements

An XML fragment with two top-level sibling elements is not a well-formed XML document. Wrap sibling fragments in a single parent container tag.

Namespace Prefixes in Tags

Prefixed tags like <soap:Envelope> must match their exact prefix in the closing tag (</soap:Envelope>).

Frequently Asked Questions

Does this XML formatter and XPath tester process SOAP or SAML payloads locally?

Yes. All XML tag-stack validation, pretty-printing, minification, XPath evaluation, and XML-to-JSON conversion execute 100% client-side in your browser with zero server uploads.

How are XML attributes represented when converting XML to JSON?

Element attributes are prefixed with @ (for example, "@id": "srv-101") and mixed text content is stored under "#text", preventing collisions between attribute names and child element tags while grouping repeated sibling tags into JSON arrays.

What XPath syntax is supported in the live evaluator?

The evaluator supports absolute paths (/catalog/service), recursive descendant searches (//service), attribute equality predicates (//service[@env="production"]), text extraction (/text()), and attribute extraction (/@id).

How do I minify XML without breaking whitespace inside text nodes?

Switch to the Minified XML tab. The minifier strips <!-- ... --> comments and inter-element indentation whitespace between > and < while keeping text inside leaf elements intact.

Why does my XML fail validation on unclosed tags like <br> or <img>?

Unlike HTML5, strict W3C XML 1.0 has no implicit void elements. Every XML tag must either have a matching closing tag (<br></br>) or use self-closing syntax (<br/>).