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.

Two settings shape the result: the name of the root element and whether an XML declaration line goes at the top. The JSON is turned into XML on this page and is never uploaded.

How to Use This Tool

1

Paste JSON

Drop a JSON payload on the left, or load one with Upload. Sample gives you something to experiment with. The settings icon is where you rename the root element and switch the XML declaration on or off.

2

Review XML Output

Generated XML appears on the right. Object keys turn into 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 if a JSON key would be an illegal XML element name?

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.

Is there a way to go from XML to JSON instead?

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.