JSON ↔ XML Converter
Convert JSON data to properly formatted XML and back.
What is JSON ↔ XML Converter?
A JSON to XML converter takes a JSON document and rewrites it as a well-formed XML 1.0 tree, mapping each object key to an element name, each value to text content or nested elements, and arrays to repeated sibling elements under a wrapping root tag. The output is valid XML that any conforming parser accepts.
This JSON to XML converter runs in your browser. Paste JSON, set a root tag name, and click Convert to get formatted XML you can drop into a SOAP envelope, a legacy ERP import, or an RSS feed. Integration engineers, backend developers, and teams maintaining XML-only systems use it to bridge modern JSON APIs with the older XML pipelines those systems still require.
Why use this JSON to XML converter?
- Bridge JSON APIs with XML-only consumers. Convert an API response into the XML shape that a SOAP service, a legacy ERP, or a financial messaging system expects.
- Choose your own root tag. Configure the wrapping root element name so the output matches the schema or DTD the downstream system enforces.
- Generate readable, indented output. The result is pretty-printed with two-space indentation, ready to paste into a request body or save to a
.xmlfile. - Stay private by default. Conversion runs entirely client-side. The JSON never leaves your browser, so customer data and access tokens stay local.
- Skip the script. A one-off conversion that would normally need a Python
xmltodictsnippet takes one paste and one click.
How to use the JSON to XML converter
- Set the root tag in the Root tag name input (defaults to
root). - Paste your JSON into the input panel on the left.
- Click Convert.
- Copy the formatted XML from the output panel on the right.
Type-mapping table
| JSON | XML | Notes |
|---|---|---|
{ "user": { "id": 1 } } | <user><id>1</id></user> | Keys become element names. |
[1, 2, 3] | <item>1</item><item>2</item>... | Arrays repeat under a sibling tag. |
"hello" | hello (text content) | Special chars escaped. |
true / false | true / false | Written as text. |
null | <key/> (self-closing) | No XML null type. |
42 | 42 | Numbers as text. |
Keys that are not valid XML element names (start with a digit, contain spaces, etc.) are sanitized by the converter. Reserved characters in values (<, >, &, ", ') are escaped to their XML entities (<, >, &, ", ').
Worked example
A typical API payload:
{
"order": {
"id": "A-1024",
"customer": "Ada Lovelace",
"items": [
{ "sku": "B100", "qty": 2 },
{ "sku": "B204", "qty": 1 }
]
}
}Converts with a root tag of envelope to:
<envelope>
<order>
<id>A-1024</id>
<customer>Ada Lovelace</customer>
<items>
<sku>B100</sku>
<qty>2</qty>
</items>
<items>
<sku>B204</sku>
<qty>1</qty>
</items>
</order>
</envelope>The array of items becomes repeated <items> siblings, which is how most XML schemas represent collections.
Common use cases
- Integration engineers calling SOAP services. Convert a modern JSON request into the XML body a SOAP envelope requires.
- Backend developers writing data exports. Translate a JSON record into XML for systems that only accept XML uploads (banking, healthcare, government).
- Operations teams importing into legacy ERPs. Move data from a JSON API into the XML schemas that SAP, Oracle EBS, and older NetSuite pipelines still expect.
- API consumers debugging XML feeds. Round-trip a JSON example into XML to confirm the shape matches a partner’s documented schema.
- Tech writers documenting hybrid APIs. Generate XML examples from a single canonical JSON source so JSON and XML docs stay in sync.
Frequently asked questions
How does the converter handle JSON arrays?
Arrays become repeated sibling elements under a wrapping tag. So {"items": [1, 2]} produces <items>1</items><items>2</items>. This matches the most common XML convention for collections. If you need an explicit wrapping element with <item> children, restructure the JSON before converting.
Can I add XML attributes to elements?
Not from a flat JSON object, since JSON has no distinction between attributes and child elements. To inject attributes, follow a convention like prefixing attribute keys with @ and have your downstream consumer interpret them, or post-process the output. The converter emits everything as elements.
What does the converter do with reserved XML characters?
Values containing <, >, &, ", or ' are escaped to the XML entities <, >, &, ", and '. This keeps the output well-formed even when string values contain markup. The reverse round-trip un-escapes them.
Does the output include an XML declaration?
The converter emits only the document body, not the <?xml version="1.0" encoding="UTF-8"?> declaration. Add the declaration manually if the consumer requires it. Most parsers accept XML without a declaration and assume UTF-8.
What happens if a JSON key is not a valid XML element name?
XML element names must start with a letter or underscore and cannot contain spaces or many punctuation characters. Invalid characters are sanitized by the converter (usually replaced with _) so the output is well-formed. If precise naming matters, rename keys in the JSON before converting.
Is there a CSV-style header row in XML?
No. XML is self-describing: every value carries its element name as a tag. Unlike CSV, there is no separate header row. Each record duplicates the structure, which is more verbose but also more explicit.
Can the tool convert XML back to JSON?
This tool converts in one direction (JSON to XML). For the reverse, use an XML-aware parser like xml2js (Node), xmltodict (Python), or a dedicated XML to JSON tool. Round-tripping XML to JSON loses attributes and namespace prefixes unless you preserve them with a convention.
Related tools
- JSON Formatter & Diff: Pretty-print JSON and compare two payloads.
- JSON Validator: Check JSON syntax and pinpoint the exact line of any error.
- JSON Minifier: Strip whitespace and compress JSON to its smallest valid form.
- XML Prettify: Format and indent XML documents for readability.
Related tools
JSON Formatter & Diff
Paste two JSON payloads and see the real diff with collapsible tree, key search, and copy-as-JSON-path.
Open toolJSON Validator
Paste JSON and instantly see if it's valid, with the exact line and character of any error.
Open toolJSON Minifier
Strip whitespace and compress JSON to its smallest valid form.
Open toolShotMark captures what you do here, in one click.
The traces, payloads, and tests you run by hand? ShotMark grabs the whole bug and hands it to your AI agent.