JSON ↔ XML Converter

Convert JSON to XML and back, or pretty-print XML, entirely in this tab. Elements, attributes (the @_ prefix convention) and text nodes are mapped between the formats. XML→JSON→XML round trips can normalize markup. Use it for SOAP payloads, legacy APIs and config that still lives in XML. Neither document is sent over the network.

JSON
XML
Converted on this deviceNothing leaves this tab

Runs in this tab · nothing is uploaded · Verify in 10 seconds →

What the JSON ↔ XML converter does

This converter turns XML documents into JSON and JSON back into XML, useful for legacy SOAP responses, RSS feeds, sitemaps, Maven or Android config files, and any API that still speaks XML. A pretty-print action reindents messy XML without converting it.

How the JSON ↔ XML converter works

Conversion uses the fast-xml-parser library entirely in this tab. XML → JSON first validates the markup (so you get a real error with line and column), then parses elements into objects, repeated elements into arrays, and attributes into keys prefixed with @_. JSON → XML reverses the mapping: object keys become elements and @_-prefixed keys become attributes. Pretty-print reparses the XML preserving element order and comments, then rebuilds it with two-space indentation.

~/faq

Frequently asked questions

How are XML attributes represented in JSON?

As object keys prefixed with @_. So <book id="bk101"> becomes {"book": {"@_id": "bk101", …}}. Going the other way, any key starting with @_ is emitted as an attribute on its parent element.

Is XML → JSON → XML a lossless round trip?

Not always. JSON has no concept of comments, processing instructions, CDATA sections or the XML declaration, so those are dropped. Text that looks numeric ('39.95') comes back as a JSON number, and a single child element cannot be told apart from a one-item list, so a round trip can normalize the document even when the data survives.

Why did my element order change?

A JSON object groups repeated elements under one key, so siblings with different names that were interleaved in the XML are regrouped by name after a round trip. W3C XML 1.0 makes sibling order significant; JSON objects do not, which is the core mismatch between the two formats.

What JSON can become XML?

An object whose keys are valid XML element names works best. If the root is an array or a primitive, the tool wraps it in a <root> element (and says so in the status bar), because an XML document must have exactly one root element. Keys with spaces or other characters that are illegal in element names will produce invalid XML.

Is my data uploaded to convert it?

No. Validation, parsing and building all run in this tab with the fast-xml-parser library. Nothing you paste leaves your device.