Embed this tool on your site
<iframe src="https://devtoolbox.dedyn.io/tools/xml-json-converter" width="100%" height="700" frameborder="0" title="XML to JSON Converter"></iframe>

XML to JSON Converter

Convert between XML and JSON formats instantly. Configurable attribute handling, array detection, pretty printing, and more. Everything runs in your browser — your data stays private.

Options
 
Drop file here
Converted output will appear here...

About XML & JSON Conversion

XML (eXtensible Markup Language) and JSON (JavaScript Object Notation) are two of the most widely used data interchange formats. XML has been the standard for enterprise systems, SOAP APIs, configuration files, and document formats like SVG and RSS. JSON has become the dominant format for REST APIs, web applications, and modern configuration files due to its simplicity and native JavaScript support.

Converting between these formats is a common task when integrating legacy systems with modern APIs, migrating data, or working with tools that expect a specific format. This converter handles the full range of XML features including attributes, namespaces, CDATA sections, mixed content, and deeply nested structures.

Key Features

How Attributes Are Handled

XML attributes have no direct equivalent in JSON, so the converter offers three strategies. The @attributes object approach groups all attributes under a dedicated key, keeping them separate from child elements. The prefix with @ option places each attribute alongside child elements with an @ prefix. The merge option combines attributes directly with element content, which produces the most compact output but may cause key collisions.

Frequently Asked Questions

How does the XML to JSON conversion handle XML attributes?
XML attributes can be converted in several ways: grouped into an '@attributes' object, prefixed with '@' as sibling keys, or merged directly with child element content. You can choose the method that best fits your use case using the Attribute Handling option. The default '@attributes' approach is the most explicit and avoids naming collisions.
Is my XML or JSON data sent to a server?
No. This XML to JSON converter runs 100% in your browser using JavaScript and the built-in DOMParser API. Your data never leaves your computer. No server requests are made during conversion, so it is completely safe for sensitive or proprietary data. You can even use it offline after the page loads.
How are repeated XML elements handled when converting to JSON?
When multiple sibling elements share the same tag name, they are automatically grouped into a JSON array. For example, '<items><item>A</item><item>B</item></items>' becomes '{"items":{"item":["A","B"]}}'. You can also enable 'Force Arrays' to wrap every element value in an array for consistent structure, which is useful for programmatic processing.
Keyboard Shortcuts
Ctrl+Enter Convert
Ctrl+Shift+C Copy output
Ctrl+L Clear