XML to JSON Converter

Convert XML to JSON
online, free & instant

Paste your XML and get clean, structured JSON output in one click. Attributes, nested elements, and namespaces are all preserved. No signup, no server — runs entirely in your browser.

Open XML to JSON Converter

XML to structured JSON in three steps

Paste your XML Drop any valid XML document — SOAP envelopes, config files, API responses, RSS feeds, or custom schemas.
Automatic structure mapping Elements become objects, repeated siblings become arrays, attributes get an @ prefix. The hierarchy is fully preserved.
Copy the JSON result One-click copy puts the formatted JSON on your clipboard, ready for your application, API, or database.
Also converts JSON to XML Need the reverse? The same Convert tab supports JSON to XML, YAML, CSV, SQL, and 15+ other formats.

No account. No upload. No nonsense.

🔒

Fully Private

Your XML data never leaves your device. All parsing happens in JavaScript, right in your browser.

🏗️

Preserves Structure

Attributes, namespaces, nested elements, and mixed content are all mapped to a clean JSON representation.

Instant Results

No server round-trips. The converter responds immediately, even for large XML documents.

Related JSON tools

JSON to YAML Convert JSON to clean, readable YAML configuration in one click.
JSON to CSV Export JSON arrays as spreadsheet-ready CSV files compatible with Excel and Google Sheets.
JSON Schema Validator Validate JSON against a Draft-07 schema or generate a schema from sample data.
JSON Repair Fix broken JSON — trailing commas, unquoted keys, Python literals and more.

Common questions answered

Is the XML to JSON converter free?

Yes, completely free with no account or signup required. Use it unlimited times.

How are XML attributes handled in the JSON output?

XML attributes are converted to JSON properties prefixed with '@' (e.g., @id, @class). This convention preserves the attribute data while keeping it distinguishable from child elements.

Does the converter support XML namespaces?

Yes. Namespace prefixes are preserved in the JSON key names (e.g., 'soap:Envelope'), so you retain the full structure of your XML document.

Is my XML data sent to a server?

No. All parsing and conversion happens entirely in your browser using JavaScript. Your data never leaves your device.

How are nested XML elements converted to JSON?

Nested child elements become nested JSON objects. Repeated sibling elements with the same tag name are automatically grouped into JSON arrays, preserving the hierarchical structure.

Converting XML to JSON

XML to JSON conversion transforms hierarchical markup into compact JSON. This is common when integrating with SOAP APIs, processing RSS/Atom feeds, reading Android resources, or migrating from XML-based systems to modern JSON APIs. The conversion reduces verbosity significantly.

XML attributes become JSON properties (prefixed with @), text content maps to #text, repeated elements become arrays, and namespaces are preserved or stripped. This tool handles all these edge cases, producing clean JSON from any well-formed XML. Mixed content (elements with text and children) uses a consistent mapping strategy.

Convert XML to JSON
Input
<?xml version="1.0"?>
<user role="admin">
  <name>Alice</name>
  <age>30</age>
  <tags>
    <tag>dev</tag>
    <tag>lead</tag>
  </tags>
</user>
Output
{
  "user": {
    "@role": "admin",
    "name": "Alice",
    "age": "30",
    "tags": {
      "tag": ["dev", "lead"]
    }
  }
}

Get the most out of this tool

Ready to convert your XML?

Free forever. No signup. Instant results.

Convert XML to JSON now

How XML-to-JSON conversion works

XML and JSON represent fundamentally different data models, making their conversion a non-trivial mapping problem. XML is a document format with a tree of nodes — elements, attributes, text content, CDATA sections, comments, and processing instructions. JSON is a data format with a tree of values — objects, arrays, strings, numbers, booleans, and null. Converting XML to JSON requires making decisions about how each XML concept maps to these JSON primitives.

Element text content is typically placed in a special key like #text or _text when an element also has attributes or child elements. For example, <name lang="en">Alice</name> might become {"name": {"lang": "en", "#text": "Alice"}}. This convention preserves both the attribute and the text content without losing information, though it produces more verbose JSON than a simple {"name": "Alice"} would.

XML attributes present a mapping challenge because JSON objects have no concept of attributes — only keys and values. The most common approach prefixes attribute names with @ to distinguish them from child elements: {"element": {"@id": "123", "child": "value"}}. Alternative approaches merge attributes directly into the object or place all attributes in a dedicated $ or _attr key. The chosen convention must be consistent and documented when sharing converted JSON with other systems.

Repeated XML sibling elements of the same name should become a JSON array. The challenge is that an element appearing once and an element appearing multiple times look structurally identical when viewed in isolation. A robust converter scans all children of a node before deciding whether to use an array — if a tag name appears more than once among siblings, it becomes an array; if it appears only once, it may be either a single value or a single-element array depending on the converter's configuration.

XML namespaces add another layer of complexity. A namespaced element like <soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> must be handled either by stripping the namespace prefix, including it in the key name ("soap:Body"), or expanding it with the full URI. Most practical XML-to-JSON converters strip namespace prefixes or include them verbatim, with full namespace URI expansion reserved for semantic web applications.

SOAP and WSDL web services — common in enterprise Java, .NET, and SAP systems — produce heavily nested XML with namespaces, envelope structures, and type annotations. Converting SOAP responses to JSON is often the first step in building a REST adapter over a legacy SOAP service. The converted JSON can then be cleaned up with transformation steps to remove envelope boilerplate and expose only the business data.

RSS and Atom feeds are XML formats used for blog syndication and news aggregation. Converting them to JSON enables consumption by JavaScript applications that natively handle JSON but would require an XML parsing library to handle the original feed format. JSON-formatted feed data can be stored in document databases, filtered with JSONPath, and served via REST APIs to feed reader applications.

When developers convert XML to JSON

Modernizing SOAP web service integrations Legacy SOAP services return XML responses that modern JavaScript and Python clients prefer to handle as JSON. Converting SOAP response XML to JSON bridges the generational gap, allowing new application code to work with familiar JSON structures instead of XML DOM parsers.
Parsing RSS and Atom feeds News aggregators, podcast apps, and content pipelines that consume RSS or Atom feeds convert the XML feed to JSON for storage in document databases, processing with jq or JSONPath, and serving to front-end applications that expect JSON APIs.
Integrating with enterprise ERP systems SAP, Oracle, and legacy ERP systems frequently export data as XML. Converting this XML to JSON enables integration with modern microservices and cloud APIs that expect JSON, without the overhead of maintaining XML parsing code in every downstream service.
Processing government and public data APIs Many government data portals, healthcare (HL7, FHIR XML), and financial reporting systems (XBRL) provide data in XML format. Converting to JSON makes this public data accessible to modern analytics tools, data science libraries, and visualization platforms.

XML-to-JSON conversion pitfalls

Additional frequently asked questions

How are XML attributes handled in the JSON output?

XML attributes are typically represented as object properties prefixed with @ to distinguish them from child elements. For example, <item id="1"> becomes {"item": {"@id": "1"}}. Some converters use a dedicated _attributes key instead. The exact convention varies by converter — check your tool's documentation to understand the mapping used.

What happens to XML comments and processing instructions?

XML comments (<!-- ... -->) and processing instructions (<?xml-stylesheet ... ?>) have no JSON equivalents and are discarded during conversion. If comments contain important information like field descriptions or version markers, extract that information into dedicated JSON properties before converting.

Can I convert XML with CDATA sections to JSON?

CDATA sections (<![CDATA[...]]>) wrap raw text content that contains characters which would otherwise need XML escaping, like < and &. During XML-to-JSON conversion, CDATA content is treated as plain text — the CDATA wrapper is removed and the raw text becomes a JSON string value, with no escaping artifacts.

Is there a way to convert only part of an XML document to JSON?

XPath expressions can extract specific nodes from an XML document before conversion. For example, if you only need the <items> section of a large SOAP envelope, extract that subtree with XPath first and then convert it to JSON. Command-line tools like xmllint support XPath extraction that can be piped into an XML-to-JSON converter.