JSON to XML Converter

Paste a JSON object and convert it to well-formed XML instantly.

🔒 100% private — runs entirely in your browser

or try sample data

What is JSON to XML?

JSON to XML converts a JSON object into well-formed XML. Each JSON key becomes an XML element, arrays become repeated elements, and keys prefixed with @ become XML attributes.

The converter produces a complete XML document with an XML declaration. You can customize the root element name, enable pretty-printing with indentation, and use the #text key convention for mixed content elements.

This is useful for integrating with SOAP services, generating XML configs from JSON data, or converting modern JSON APIs into XML format for legacy systems. All conversion happens in your browser.

JSON to XML — Conversion Examples

@attributes and nested objects

{ "user": { "@id": 42, "@role": "admin", "name": "Alice", "email": "alice@example.com" }
} // Converts to:
<user id="42" role="admin"> <name>Alice</name> <email>alice@example.com</email>
</user>

Arrays become repeated elements

{ "items": { "item": ["Apple", "Banana", "Cherry"] }
} // Converts to:
<items> <item>Apple</item> <item>Banana</item> <item>Cherry</item>
</items>

JSON to XML Gotchas

Root element handling

If your JSON has a single top-level key, it becomes the root element automatically. With multiple top-level keys, a wrapping <root> element is added (customizable via the Root Element input).

Array element naming

Arrays use the key name for each repeated element. "items": [1, 2, 3] produces <items>1</items><items>2</items><items>3</items>. For singular element names, structure your JSON with a wrapper object.

Special characters

XML special characters (& < > " ') in values and attributes are automatically escaped. JSON keys used as element names should be valid XML names (no spaces or special characters).

Frequently Asked Questions

How do I convert JSON to XML?

Paste your JSON object into the input panel and click "Convert to XML". Keys become elements, @-prefixed keys become attributes, and arrays become repeated elements.

Can I set a custom root element?

Yes. Type the desired root element name in the "Root element" input. If left empty and your JSON has a single top-level key, that key is used as the root automatically.

How are null values handled?

Null values produce self-closing XML elements: <fieldName/>.

Does it support XML namespaces?

You can include namespace attributes using the @xmlns convention, e.g., "@xmlns": "http://example.com".

Is my data safe?

Yes. All processing happens in your browser. Nothing is sent to any server.