JSON to XML Converter

Convert JSON data to XML. @attributes becomes element attributes, #text becomes text content, and arrays become repeated sibling elements — the reverse of our XML-to-JSON converter, right in your browser.

Usage tips

  • Put an object under an `@attributes` key and each of its properties becomes an attribute on the converted element.
  • Use a `#text` key to hold text content for an element that also has attributes or child elements. A simple element with no attributes can just use a plain string as its value.
  • Give the same key an array and each item is output as a repeated sibling element sharing that name.
  • A value of `null` produces an empty, self-closing tag (``) with no attributes, text, or children.
  • This tool expects input in the format our "XML to JSON converter" produces (an object keyed by the root element name, with exactly one top-level key).

Frequently asked questions

A key named `@attributes` holding an object turns each of that object's properties into an attribute on the converted XML element. For example, `{"@attributes": {"category": "fiction"}}` converts to a `category="fiction"` attribute.

Giving the same key an array outputs each array item as a repeated sibling element with that name. For example, `"book": [{"title": "A"}, {"title": "B"}]` converts to XML containing two `` tags.

The most common cause is a JSON syntax error (a missing comma or unquoted key). XML also requires exactly one root element, so JSON with multiple top-level keys, or a JSON array at the root, will also fail.

Yes — our "XML to JSON converter" handles the reverse direction. Since both tools use the same conversion convention, content survives a round trip in either direction.

This tool assumes the convention used by the "XML to JSON converter" (`@attributes`, `#text`, arrays, and null). Freely-structured JSON that doesn't follow this convention — like a typical API response full of numbers and booleans — may not convert into the XML structure you'd expect.
ツールくん

Side Note — What to watch for when converting JSON back into XML

Converting XML to JSON is a bit like compressing information. XML can carry three kinds of information — attributes, text, and child elements — while JSON only has plain key-value pairs, so some convention has to be adopted at conversion time (this tool follows the same four rules: `@attributes`, `#text`, arrays, and null). As long as that convention is followed, converting JSON back into XML is a mechanical, well-defined process — but forcing freely-structured JSON that doesn't follow the convention into XML can leave it unclear what should become an attribute versus an element, and the result may not match what you expected.

In practice, this comes up when a legacy XML API response is converted to JSON for easier processing in JavaScript, then converted back to XML to send to another system — for instance, reshaping a SOAP API response as JSON before sending it back out as a SOAP-style request. In this kind of round trip, keeping the conversion convention consistent matters most; mixing in a tool that uses a different convention partway through can scramble the relationship between attributes and text.

This tool strictly requires exactly one top-level key because that reflects a rule of XML itself — a document must have exactly one root element. If you need to convert JSON with multiple top-level keys, wrap it in a common parent key (e.g. `root`) beforehand, and it will convert cleanly into XML with a single root element.