JSON to XML Converter

In short: JSON out as well-formed XML, with a documented convention for the parts JSON cannot say: keys starting with @_ become attributes, a #text key becomes element text, and arrays become repeated elements. The convention is the exact mirror of this site’s XML to JSON converter, so the two round-trip — and everything runs in your browser.

The mapping, stated plainly

JSON and XML do not model the world the same way, and any converter that hides that fact will eventually corrupt your data silently. XML has attributes and text content; JSON has neither. XML element names must be legal names; JSON keys can be anything. XML is ordered text; JSON objects are unordered key sets. So this page states its convention up front, the same one used by the popular fast-xml-parser library and by this site’s XML to JSON Converter in reverse:

JSONXML
{"@_id": "bk101"}an attribute: id="bk101"
{"#text": "hello"}the element’s text content
{"tag": ["a", "b"]}repeated elements: <tag>a</tag> <tag>b</tag>
{"a b": 1} (illegal XML name)renamed to <item> rather than emitting broken XML
nullan empty element: <key/>

Text and attribute values are escaped properly — ampersands, angle brackets and quotes can never break out and corrupt the document — and the output carries the standard <?xml version="1.0" encoding="UTF-8"?> declaration. One asymmetry deserves honesty: numbers and booleans become text in XML, and XML has no types, so converting back gives strings — 44.95 returns as the text “44.95”, not the number. That is a property of XML itself, not of this page, and it is why the round trip is exact for structure and text but not for scalar types.

Why anyone still converts to XML

Because large parts of the world’s plumbing never left it: SOAP services and their WSDL contracts, RSS and Atom feeds, SVG images, Office document formats, SAML identity assertions, Maven and Android configuration, sitemaps (including this site’s own), and a long tail of banking, government and enterprise interfaces whose schemas are written in XSD. The everyday jobs for this page are feeding a legacy service from a modern API’s JSON, generating a sitemap or feed prototype, producing test fixtures for an XML consumer, and checking that a JSON payload survives the mapping before a real integration depends on it. The family on this site covers the circuit: XML to JSON for the inbound direction, JSON to YAML for configuration, and the JSON Formatter for repairing the payload before either journey.

A worked example

The default input — a book with an attribute, using the @_ convention — converts to:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <book id="bk101">
    <title>XML Guide</title>
    <price>44.95</price>
    <tags>xml</tags>
    <tags>json</tags>
  </book>
</root>

The @_id key became the attribute, the array became two repeated <tags> elements, and the number became text — exactly the documented mapping, and exactly what this site’s XML to JSON Converter turns back into the original JSON (with the price returning as the string "44.95", per the type note above). Rename the root element in the field at the top and the wrapper changes with it — useful when a receiving system expects <catalog> or <order> rather than <root>.

Frequently asked questions

How do attributes work in the conversion?

With the @_ convention: a key that starts with @_ becomes an attribute of its element, named by the rest of the key — @_id becomes id="...". A #text key becomes the element’s text content when it sits alongside child elements. Both conventions are shared with the fast-xml-parser library and with this site’s XML to JSON Converter, so JSON produced by that converter — which emits exactly these key forms — converts back to the original XML structure. Plain keys always become child elements.

Why did my array become repeated elements?

Because that is XML’s only native way to hold a list. XML has no array type; a sequence of values with the same meaning is expressed as sibling elements with the same name, which is how RSS items, sitemap URLs and order lines all work. When the XML is converted back with the matching convention, siblings with the same name are gathered back into an array. If your target system instead expects a wrapper element with item children, name the root accordingly and treat the repeated elements as the items — or restructure the JSON as {"items": {"item": [...]}}-style nesting before converting.

Why did one of my keys get renamed to item?

Because it was not a legal XML element name. XML names must start with a letter or underscore and contain only letters, digits, hyphens, underscores and dots — a key like "a b", "1st" or "price ($)" cannot appear as a tag without producing malformed XML that no parser will accept. Rather than emit broken output, the converter renames such keys to item and keeps the value. If the name matters, rename the key in the JSON first; the converter will then use it verbatim.

Will my numbers and booleans stay numbers and booleans?

In the XML they become text, because XML has no scalar types — <price>44.95</price> holds the characters 44.95, and any schema or parser on the receiving end decides what they mean. Converting the XML back to JSON therefore yields strings for those values. Structure, attributes and text round-trip exactly; scalar types do not, and any converter claiming otherwise is quietly guessing from the text’s shape. If types matter downstream, carry them in an XSD schema or a parallel field rather than relying on the text.

Is my JSON uploaded anywhere?

No — the conversion runs entirely in your browser, and nothing you paste is transmitted, logged or stored. That matters for this converter in particular: payloads bound for legacy enterprise systems are exactly the ones full of internal identifiers, account references and test data that should not travel. You can confirm it in your browser’s network monitor: converting produces no requests. The Download button simply saves the output box as an .xml file from the page itself.

Related tools

Mapping convention matches the fast-xml-parser attribute convention, checked on 24 November 2026. Everything runs in your browser — nothing you paste is sent anywhere.