What This Tool Does

This converter translates JSON documents into well-formed XML and parses XML back into JSON. It preserves attributes (prefixed with @), text content (stored as #text), nested structures, and arrays (as repeated elements). Useful for integrating modern JSON APIs with legacy SOAP or XML-based systems.

Inputs Explained

How It Works

JSON to XML: recursively walks the JSON tree, emitting opening/closing tags for each key, with arrays producing repeated elements. XML to JSON: parses XML with DOMParser, walking elements into a JSON tree where attributes become @attr properties and text content becomes #text.

Formula / Logic Used

JSON→XML: for each key, emit value; arrays repeat element XML→JSON: attributes → '@name', text → '#text', children → object/array

JSON to XML & XML to JSON Converter

Convert between JSON and XML with full attribute and nested structure support.

Step-by-Step Example

Input JSON:

{"book":{"@id":"1","title":"Guide","author":"Ramesh"}}

Output XML:

<?xml version="1.0" encoding="UTF-8"?>
<book id="1">
  <title>Guide</title>
  <author>Ramesh</author>
</book>

Use Cases

Assumptions and Limitations

Disclaimer: Conversion runs entirely in your browser using native DOMParser and JSON APIs. No data is sent to any server.

Frequently Asked Questions

Why are some JSON keys prefixed with @?

The @ prefix indicates an XML attribute. For example, {"book":{"@id":"1"}} converts to . This is the standard Badgerfish/Parker convention for JSON-XML mapping.

What does #text mean in the JSON output?

When an XML element has both attributes and text content (mixed content), the text is stored under the #text key. For example,

Hello

becomes {"p":{"@class":"intro","#text":"Hello"}}.

How are XML arrays represented in JSON?

Repeated XML elements with the same tag name become JSON arrays. AB becomes {"items":{"item":["A","B"]}}.

Are XML comments preserved?

No. Comments, CDATA sections, and processing instructions are stripped during conversion. Only elements, attributes, and text content are preserved.

Can I convert XML with namespaces?

Partially. Namespace prefixes (like xs:element) become part of the element name in JSON. Namespace declarations (xmlns) are preserved as attributes. Full namespace-aware conversion requires manual handling.

What's the difference between XML and JSON?

JSON is more compact and directly maps to JavaScript objects. XML supports attributes, namespaces, schemas, and mixed content natively. JSON is preferred for modern web APIs; XML is common in enterprise and legacy systems.

Is my data stored anywhere?

No. Conversion happens entirely in your browser using DOMParser and JSON.parse. Data never leaves your device.

Can the tool handle very large XML files?

Modern browsers can parse several MB of XML in the browser. For files over 10 MB, performance may degrade depending on your device.

Sources and References

Related Calculators

JSON FormatterJSON to CSVYAML to JSONHTML EntitiesBase64 EncoderURL Encoder