JSON to XML
Convert JSON to XML and back, with automatic root-element wrapping.
JSON input
XML output
Enter JSON on the left to convert it.
What is JSON to XML?
A JSON to XML converter re-serializes JSON data as an XML document — nested tags instead of nested braces. This is the direction you need when a consumer on the other side speaks XML exclusively: a SOAP web service request body, a legacy enterprise integration, an RSS/Atom-style feed structure, or configuration formats used by older tooling. The conversion isn't purely mechanical: JSON allows a document with several top-level keys or a bare array, while XML requires exactly one root element, so the converter makes a sensible choice about how to wrap or group data — a single top-level key whose value is an object becomes the root tag directly, and anything else is wrapped under a synthetic <root>. Output is prefixed with a standard `<?xml version="1.0" encoding="UTF-8"?>` declaration, and because XML has no dedicated way to represent a null, a JSON `null` and an empty string both collapse to the same self-closing tag (`<a/>`) — worth knowing before you convert a document with nullable fields.
How to use JSON to XML
- Paste or type your JSON into the left panel — an object, an array, or any JSON value works.
- The XML appears instantly on the right, syntax-highlighted, with the <?xml ...?> declaration already in place.
- Check how the root was chosen — a single top-level key with an object value becomes the root tag; anything else is wrapped under <root> so the document stays valid.
- Click "Load sample" to see a worked example, or copy the result once you're happy with it.
Examples
Object with a single root-shaped key
Input
{"user": {"name": "Ada", "id": 1}}
Output
<user> <name>Ada</name> <id>1</id> </user>
Multi-key object (wrapped in a synthetic root)
Input
{"name": "Ada", "active": true}
Output
<root> <name>Ada</name> <active>true</active> </root>
Null and empty string collapse to the same tag
Input
{"bio": null, "nickname": ""}
Output
<root> <bio/> <nickname/> </root>
Common mistakes
- Expecting XML output with no wrapping root tag when the source JSON has multiple top-level keys or is a bare array — XML's single-root rule makes some wrapping unavoidable.
- Assuming the output will contain XML attributes — this converter emits only child elements, so every key becomes a tag and no id="..."-style attributes are produced.
- Forgetting that null and an empty string become the same self-closing tag (<a/>) — XML has no native null representation, so a nullable field's state is lost on the way out.
- Hand-escaping angle brackets and ampersands in the JSON before converting — the writer escapes & < > automatically, so pre-escaped input like "a & b" would be double-escaped in the XML.
- Expecting an array with one item to look structurally different from a single value — both become a single tag at that position, because XML repetition only appears with two or more sibling tags.
Why use this tool
- Runs entirely client-side — no document you convert is ever sent to a server.
- Automatically picks a sensible root element instead of forcing you to manually restructure JSON before conversion.
- The root-tag and array-wrapping rules are deterministic — the same JSON shape always produces the same XML structure, so you don't have to make a fresh wrapping decision on every conversion.
- Escapes special characters (&, <, >) correctly, so arbitrary string values produce well-formed XML that any standard parser accepts.