JSON to XML Converter

Produce well-formed XML from JSON, with control over roots and array naming.

JSON input
XML output

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

  1. Paste your JSON, or drop a .json file onto the input pane.
  2. Name the root element (the default root is fine for testing; real consumers usually want something specific).
  3. 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?
Prefix the key with @_: {"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?
The element repeats once per item — {"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?
Keys starting with a digit, or containing characters XML forbids, are made safe — 1abc becomes _1abc — and every rename is stated in the notes, so nothing changes silently.
Can it produce a declaration or namespaces?
The output is a well-formed element tree. A declaration (<?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.
Is my data uploaded anywhere?
No. Conversion runs locally; a dropped file is read in the tab and never sent anywhere.