Home XML to JSON

XML to JSON

Convert XML to formatted JSON instantly — handles nested elements and text nodes, 100% in your browser.

Input

Output

Original
Result
Type

What is XML?

XML (eXtensible Markup Language) is a markup language that defines rules for encoding documents in a format that is both human-readable and machine-readable. It uses tags (like HTML) to define elements, attributes, and hierarchical structure. XML was widely used for data exchange, configuration files, SOAP APIs, and document formats before JSON became the dominant web data format.

XML remains important in many legacy systems, enterprise applications, SOAP-based web services, RSS/Atom feeds, SVG graphics, and configuration files. Despite its verbosity compared to JSON, XML is still found in many production systems and file formats, making XML-to-JSON conversion a common need.

XML vs JSON

XML and JSON represent data differently. XML uses opening and closing tags with attributes, while JSON uses key-value pairs and arrays. XML can have attributes on elements (which JSON cannot natively represent), mixed content (text and child elements interleaved), and namespace prefixes. JSON is simpler, more compact, and maps directly to JavaScript objects.

The main structural difference is how they handle repetition. In XML, repeated child elements with the same tag name represent an array. In JSON, arrays are explicit with square brackets. This converter detects repeated element names and automatically converts them to JSON arrays.

When to convert XML to JSON

Converting XML to JSON is useful in many scenarios:

  • Modernising legacy APIs. Convert XML responses from SOAP or legacy REST APIs to JSON for use in modern web applications.
  • Configuration migration. Move XML configuration files to JSON format for use in modern tools and frameworks.
  • Data processing. Process XML data feeds (RSS, Atom) in JavaScript applications that expect JSON.
  • Simplifying data. Strip XML's verbosity and complexity when you only need the data values.
  • Interoperability. Bridge between XML-based systems (like SOAP) and JSON-based systems (like REST APIs).

How to convert XML to JSON

Converting XML to JSON with this tool takes a second and happens entirely in your browser. Follow these steps:

  1. Paste your XML. Enter valid XML in the input box. The root element and all its children will be converted.
  2. Click "Convert". The parser builds a DOM tree from the XML and recursively converts it to a JSON object.
  3. Copy or download. Click "Copy" to copy the JSON to your clipboard, or "Download" to save it as a .json file.

If the XML is invalid, the parser will report an error message describing the problem. Fix the XML and try again.

How the conversion works

The converter recursively walks the XML DOM tree. For each element, it creates an object with child element names as keys. If multiple child elements share the same tag name, they are automatically grouped into a JSON array. Text-only elements (leaf nodes with no children) are converted to string values. Mixed content (both text and child elements) uses a #text key for the text portion.

Note that XML attributes are not converted — only element content is processed. This keeps the JSON output clean and simple. If you need attributes, consider preprocessing your XML to convert attributes to child elements. Also, namespace prefixes in tag names are preserved as-is in the JSON keys, so <ns:foo> becomes "ns:foo" in the JSON.

Is this XML to JSON converter free?

Yes, completely free with no sign-up, no limits beyond your device's memory, and no upload.

Are XML attributes converted?

No. This converter processes element content only, not attributes. This keeps the JSON output clean. Convert attributes to child elements in your XML if you need them in the JSON.

How are repeated elements handled?

If multiple child elements share the same tag name, they are automatically grouped into a JSON array. Single child elements become object properties.

Is my data uploaded?

No. All conversion is local. Your XML data never leaves your browser.