JSON to XML Converter
Produce well-formed XML from JSON, with control over roots and array naming.
About this tool
Convert JSON to well-formed XML in your browser. Choose the root element name; everything else follows a stated mapping: object keys become elements, @_key becomes an attribute, and #text becomes text content — the same conventions the XML to JSON tool reads back.
Arrays repeat their element once per item, which is what XML consumers expect from a list. Names that XML does not allow (starting with a digit, containing spaces) are made safe, and every change is listed in the notes under the output.
Integers beyond 2⁵³−1 keep their exact digits in the XML text — the builder writes what you gave it, not what a JavaScript float rounded it to.
How to use it
- Paste your JSON, or drop a
.jsonfile onto the input pane. - Name the root element (the default
rootis fine for testing; real consumers usually want something specific). - Copy or download the XML. The notes name every element that had to be renamed for XML.
Worked example
The sample becomes a root element holding name, role and three repeating ids elements — one per array item, which is how XML expects a list.
One object, one element tree
Frequently asked questions
How do I write an attribute?
@_: {"a": {"@_id": "1", "#text": "x"}} becomes <a id="1">x</a>. It is the same convention the XML to JSON direction uses, so a document can round-trip.What happens to an array?
{"items": [{"k": "a"}, {"k": "b"}]} gives two items elements, each holding one k. That is the standard XML shape for a list, unlike nesting items under one wrapper.What if my key is not a legal XML name?
1abc becomes _1abc — and every rename is stated in the notes, so nothing changes silently.Can it produce a declaration or namespaces?
<?xml version="1.0"?>) and namespace prefixes are things real documents usually add at their own top level; add them around the converted fragment as your consumer requires.