idpixo

JSON to XML Converter

Paste JSON to get well-formed XML, using the same mapping as our XML to JSON tool: attributes @name, text #text, arrays as repeated elements. Nothing is uploaded — conversion is local.

How JSON maps to XML

JSON and XML both carry structured data but describe it differently, so a converter has to make its choices explicit. On this page the rules are fixed and stated up front: object keys beginning with @ become attributes, a #text key becomes the element's text, every other key becomes a child element, and an array becomes a repeated element. Values are escaped so the result is well-formed. This is the format-conversion counterpart to the XML formatter, which beautifies or minifies XML without changing its format. For JSON itself use the JSON formatter, and for repeatable configuration text try the cron expression generator. The convention here mirrors what our XML to JSON direction expects, so the two stay consistent.

Frequently asked questions

Is my JSON uploaded anywhere?
No. The conversion runs in your browser with a self-written JavaScript serializer. Your JSON never leaves your device and nothing is stored between visits.

What mapping convention does it use?
It is fixed to match our XML to JSON tool: object keys starting with @ become attributes, a #text key becomes the element text, and any other key becomes a child element. Keeping both directions on one convention means the output is predictable.

How are arrays handled?
An array value becomes one repeated element, one copy per item, which is how arrays are normally represented in XML. A top-level array produces one root element per item.

Can I choose the root element and formatting?
Yes. Set the root element name for the wrapping element, and choose the indentation (2, 3 or 4 spaces) or Minify for a single-line output. The XML declaration can be switched off.

What happens with keys that are not valid XML names?
Characters that XML does not allow in a name are replaced with underscores, and a leading digit or dot gets an underscore prefix, so the result stays well-formed. Special characters in values are escaped as &, <, > and ".

What if my JSON is invalid?
The output box shows a readable error instead of XML, so you can fix the JSON and convert again. Nothing is sent anywhere during the attempt.

Related: tidy JSON with the JSON formatter, validate markup with the XML formatter, build configuration strings with the cron expression generator, and browse every browser-only tool on the all tools page.

All tools →  JSON formatter →