Input JSON

Output XML

What Is JSON to XML Conversion?

Ever needed to feed a REST API response into a legacy SOAP service — or submit JSON config data to a system that only accepts XML? JSON and XML both represent structured data, but they speak different languages. JSON uses key-value pairs (see the JSON spec and RFC 8259); XML uses nested tags defined by the W3C XML standard. Converting JSON to XML maps objects to elements, properties to child elements, and arrays to repeated sibling elements. This matters for SOAP integrations, EDI pipelines, Spring/Java configs, and any system where the DOM is the only way in. Need a library? Try xml-js on GitHub.

Conversion runs in your browser. You can set a root element name and choose whether to include the XML declaration. Nothing is sent to a server.

How to Use This Tool

1

Paste JSON

Paste your JSON into the left editor or upload a file. Use Sample for example data. Click the settings icon to set the root element name and XML declaration.

2

Review XML Output

The right panel shows the generated XML. Object keys become element names; values become text content. Arrays produce repeated elements. The XML spec defines the format.

3

Download or Copy

Use Download or Copy to get the XML. For the reverse conversion, use XML to JSON. For formatting JSON first, use the JSON Formatter.

JSON to XML Examples

Here is an example of converting JSON to XML.

Example: Subscriber record

JSON input:

Input

Generated XML output:

Output

JSON vs XML

JSON is simpler and more compact; XML supports namespaces, attributes, and mixed content. The conversion maps JSON objects to XML elements. There's no single standard mapping; different tools make different choices. This tool uses a common approach: objects become nested elements, arrays become repeated elements. For more control, you might need a library like xml-js or custom code.

Frequently Asked Questions

Are XML special characters escaped automatically?

Yes. Characters like <, >, and & in JSON values are escaped to their XML entity equivalents per the W3C XML spec. This ensures the output is valid XML.

What happens with JSON keys that are not valid XML element names?

JSON keys can include spaces, numbers at the start, or other characters that are illegal in XML element names. The converter sanitizes such keys — for example, leading digits get prefixed. Always review the output if your JSON keys are unusual.

Is my JSON data sent to a server?

No. Everything runs locally in your browser using JavaScript. No data leaves your machine.

Can I convert XML back to JSON?

Yes. Use the XML to JSON converter on this site for the reverse conversion.

How does the root element setting work?

XML requires exactly one root element wrapping all content. You can set the root element name in the settings panel (default: "root"). The JSON object's keys become child elements of that root.

Related Tools

XML is defined by the W3C and W3C XML. For JSON, see json.org, RFC 8259, and MDN. See also xml-js and DOMParser.