JSON to XML Converter – Free, Online, Private
Serialize a JSON value as an XML document. Object keys become elements, arrays repeat a child tag, and keys that start with @ become attributes.
How to convert JSON to XML
- Paste JSON. A root object is the document element; an array is wrapped in <root>.
- Read the XML. Nested objects indent as child elements.
- Copy it into a SOAP fixture, a feed, or a legacy import that refuses JSON.
Mapping rules
XML elements have one name and ordered children. JSON objects have unordered keys, so this converter writes keys in the order they appear. A string, number or boolean becomes text content. An object becomes a parent element. An array repeats the property name for each item: tags: ["math"] becomes <tags>math</tags>. A root array is wrapped in <root> and each entry is an <item>, because XML allows only one root. Keys that start with @ are attributes on the parent, and a #text key is the character data mixed with child elements. That lets you round-trip the shape this site's XML parser produces.
Names and escaping
Element names must be XML Name tokens. Spaces and punctuation in a JSON key are replaced with underscores, and a key that starts with a digit gets a leading underscore. Characters that are special in XML text, ampersand, less-than and greater-than, are escaped. Attribute values are quoted. The document starts with an XML declaration that names UTF-8. There is no schema, no namespace unless the key itself contains a colon you kept, and no pretty-printer options beyond the newlines this generator inserts between children. Empty objects become empty elements.
Worked example
The sample user has id, name, active, tags and address. id and name become simple elements. active's boolean is the text true. tags becomes two <tags> elements, not one element with two children, because each array entry is a sibling. address becomes a parent with city and zip inside. If you need a single <tags><tag> wrapper, reshape the JSON to { tags: { tag: ["math", "engines"] } } before converting. Attribute form is available by renaming a field to @id if the consumer wants <user id="42">.
When not to use XML
New HTTP APIs should stay on JSON. XML is the right output when a contract already says XML: older payment gateways, some government forms, RSS items, or a Java stack that binds to JAXB. This page does not validate against an XSD and does not sign the document. It also does not expand entities from the input, because the input is JSON, not XML. The reverse page, XML to JSON, is the one that reads tags and attributes.
Frequently asked questions
Can numbers stay numbers?
XML text is always text. The characters of the number are preserved. A schema or the reverse converter decides whether to treat them as numbers again.
How are arrays encoded?
Each item repeats the property name as a sibling element. A JSON array at the root is wrapped in <root> with <item> children.
Are namespaces supported?
A key may contain a colon and it will be used as the element name. xmlns attributes can be set with an @xmlns key. There is no prefix registry beyond that.
Does this upload my JSON?
No. The XML string is built in the browser from the value JSON.parse returned.