Input XML

Output JSON

What Is XML to JSON?

XML (eXtensible Markup Language) and JSON are both used for structured data. XML uses tags and attributes; JSON uses keys and values. Converting XML to JSON means turning elements into objects, attributes into properties, and repeated elements into arrays. Many APIs and modern systems prefer JSON. This tool produces JSON from your XML.

Conversion runs in your browser. You can choose compact or formatted output. Nothing is sent to a server. The W3C XML spec defines the input format.

How to Use This Tool

1

Paste or Upload XML

Paste XML into the left editor or upload a .xml file. Use Sample for example data. Toggle Compact Output in settings for minified JSON.

2

View JSON Output

The right panel shows the converted JSON. Elements become objects; attributes may be in a separate key. Repeated elements may become arrays. Invalid XML will show an error.

3

Copy or Download

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

XML to JSON Examples

Here is an example of converting XML to JSON.

Example: Subscriber record

XML input:

Input

Generated JSON output:

Output

Where XML to JSON Helps

Converting XML to JSON is useful when integrating legacy XML APIs with modern JSON-based systems, when building web apps that consume SOAP or RSS feeds, or when migrating data pipelines to JSON. Many APIs and databases prefer JSON; this tool helps bridge the gap. Use it to inspect how your XML would look as JSON before writing conversion code.

XML to JSON Mapping

There's no single standard mapping. Elements become objects; attributes may be prefixed (e.g. @attr) or in a separate object. Text content may be in a #text key. Repeated elements typically become arrays. The exact mapping depends on the implementation. Libraries like xml-js or DOMParser are used under the hood.

Frequently Asked Questions

How are XML attributes handled?

It depends on the converter. Common approaches: a separate @attributes object, or keys prefixed with @. Check the output.

What about XML namespaces?

Namespace prefixes may appear in the JSON keys. The full URI might be in the output or stripped. Check the result for your use case.

Is my data sent anywhere?

No. Conversion runs in your browser.

Can I convert JSON to XML?

Yes. Use the JSON to XML tool.

What if my XML is invalid?

The tool will show an error. Try XML Validator first.

Related Tools

For XML, see the W3C XML specification. For JSON, see json.org and MDN JSON. For parsing XML in the browser, see MDN DOMParser. For XML-to-JSON libraries, see xml-js. For the reverse conversion, use JSON to XML.