ConvertOwl

XML to JSON — Convert XML Data to JSON Format

Convert XML documents to JSON format for use in APIs, databases, and modern JavaScript applications. Handles nested elements, XML attributes, CDATA sections, and RSS/Atom feeds. The output JSON reflects the XML structure with attributes prefixed by @_ for clarity. Useful for consuming legacy SOAP APIs, parsing RSS feeds, or processing XML data exports.

How to use this tool

  1. Paste your XML

    Paste any valid XML — data files, RSS feeds, SOAP responses, Android resource files, configuration files, or SVG data.

  2. Click Convert

    fast-xml-parser parses the XML into a JavaScript object. Element text content, attributes (prefixed @_), and nested child elements all map to JSON properties.

  3. Review the structure

    XML's hierarchical structure maps naturally to JSON objects. Elements with multiple children of the same tag become JSON arrays. Attributes appear as @_attributeName properties.

  4. Copy or download

    Copy the formatted JSON or download it as a .json file for use in your application.

Frequently Asked Questions

How do XML attributes map to JSON?

XML attributes (e.g., <person age="30">) are represented in the JSON with an @_ prefix: { "@_age": "30" }. This distinguishes attributes from child elements and is the convention used by most XML-to-JSON parsers. The root element name becomes the top-level key in the JSON.

How are repeated XML child elements handled?

When an XML element has multiple children with the same tag name (<item>A</item><item>B</item>), they're converted to a JSON array: { "item": ["A", "B"] }. When only one such element exists, it's a single value (not an array). This is a common source of bugs when consuming XML APIs — always handle both cases in your code.

Can I convert RSS or Atom feeds to JSON?

Yes. RSS feeds are valid XML and convert cleanly to JSON. The feed structure (channel, item, title, link, description, pubDate) maps directly to JSON. This is useful for consuming RSS feeds in applications that expect JSON, or for archiving feed content in databases.

What about CDATA sections in XML?

CDATA sections (<![ CDATA[...]]>) contain raw text that shouldn't be parsed as XML markup. The fast-xml-parser library extracts CDATA content as plain text in the JSON output, just like normal text nodes.

Are there limitations to XML that converts well to JSON?

XML has features with no direct JSON equivalent: processing instructions (<?...?>), DOCTYPE declarations, comments, and mixed content (elements containing both text and child elements). These are typically ignored or dropped during conversion. For simple data-carrying XML (no mixed content), conversion is lossless. For document-centric XML (like XHTML), some structure is lost.

Something not working? Report a bug