XML to JSON
Convert XML documents to JSON for APIs and modern services
XML Input
JSON Output
What is XML to JSON Converter?
If you have ever been handed a SOAP response, a vendor's product feed, or an old config file in XML and needed to feed it into a JavaScript app, you know the pain: XML is verbose, attribute-heavy, and awkward to walk in code. JSON is what most modern APIs, NoSQL stores, and front-end frameworks actually want. This converter reads your XML in the browser and turns each element into a JSON property, each set of repeated tags into an array, and each attribute into a tidy @attributes object — so you can paste the result straight into your code.
The parsing is done by the browser's built-in DOMParser, the same engine the W3C describes in the XML specification. The JSON it emits follows the structure defined by RFC 8259, so it is valid anywhere JSON is accepted. Nothing leaves your machine — there is no upload, no server round-trip, no logging.
How to Use XML to JSON Converter
- Paste Your XML – Drop a well-formed XML document into the left panel. It needs a single root element — the same rule every XML parser enforces.
- Watch It Convert – JSON appears in the right panel as you type. There is no Convert button; a short debounce keeps it snappy without re-parsing on every keystroke.
- Check the Attributes – Element attributes are collected under an
@attributeskey so they never collide with child-element names. Mixed text-and-element nodes keep their text under#text. - Inspect Repeated Tags – When a tag appears more than once under the same parent (like several
<subscriber>elements), it becomes a JSON array automatically. - Copy or Download – Use Copy to grab the JSON, or Download to save it as a .json file ready for your app or test fixture.
Pro Tip: If your XML uses namespaces (xmlns: prefixes), the prefixed tag names survive into the JSON keys verbatim (e.g. soap:Body). Most JSON consumers are fine with that, but if a key with a colon trips up a downstream parser, rename it after conversion.
Example
A short subscriber roster: repeated <subscriber> elements become a JSON array, the id attribute lands under @attributes, and each leaf element becomes a string value.
<?xml version="1.0" encoding="UTF-8"?> <subscribers> <subscriber id="1"> <subscriberId>SUB-1001</subscriberId> <msisdn>447700900142</msisdn> <plan>Unlimited 5G</plan> <roaming>true</roaming> </subscriber> </subscribers>
{
"subscriber": {
"@attributes": { "id": "1" },
"subscriberId": "SUB-1001",
"msisdn": "447700900142",
"plan": "Unlimited 5G",
"roaming": "true"
}
}Common Use Cases
Consuming Legacy SOAP and B2B Feeds
Carrier billing gateways, banking middleware, and government data exchanges still answer in XML — often wrapped in a SOAP envelope. When your service is JSON-first, converting the response is the fastest way to get usable data. Drop the body in, take the JSON out, and access fields the way your code already expects. For the envelope structure itself, the W3C SOAP recommendation is the reference.
Migrating XML Config to JSON
Plenty of telecom network elements (HSS, MME, SGSN) and older Java apps load settings from XML. If you are moving a project to a JSON-based config (or just want to diff two configs more easily), convert the XML here first. The MDN XML introduction is handy when you are double-checking how a particular structure maps over.
Turning RSS, Atom, or Sitemaps Into Data
RSS and Atom feeds and sitemap.xml files are all XML. Converting them to JSON makes it trivial to loop over entries in JavaScript, store them in a document database, or pipe them into a dashboard. The W3Schools XML tutorial covers the feed formats if you need a refresher.
Key Features
- Real-Time Conversion – JSON updates as you type; no Convert button to click.
- Attribute Handling – Attributes are grouped under
@attributesso they never clash with child elements. - Automatic Arrays – Repeated sibling tags collapse into a JSON array, matching how most XML-to-JSON mappers behave.
- Mixed Content Support – Elements that hold both text and child tags keep their text under a
#textkey. - Privacy First – Parsing runs entirely in your browser using DOMParser; nothing is uploaded.
Frequently Asked Questions
How are XML attributes represented in the JSON?
Each element's attributes are gathered into an @attributes object on that element. So <subscriber id="1"> becomes { "@attributes": { "id": "1" } }. This keeps attribute names from colliding with child-element names that happen to match.
What happens with repeated elements?
The first occurrence creates a single object. As soon as a second sibling with the same tag name appears, the value is promoted to an array and every occurrence is pushed into it. That is why two <subscriber> tags become a JSON array but a lone one stays a single object — a quirk worth remembering when downstream code expects an array.
Are values typed as numbers or booleans?
No. XML has no type information, so every leaf value comes through as a string ("45.2", not 45.2). If you need real numbers or booleans, cast them in your code after conversion, where you know the intended type.
Does it handle XML namespaces?
Yes, in the sense that prefixed tag names (soap:Body, ns:Item) are preserved as-is in the JSON keys. The converter does not resolve namespace URIs or strip prefixes — it keeps the literal names so the output is predictable.
Is my data safe?
Yes. The conversion uses the browser's DOMParser and runs entirely client-side. Neither the input XML nor the output JSON is sent over the network, cached, or logged.
Related Tools
- JSON to XML – Going the other direction — turn JSON back into XML for an XML-only system.
- JSON Formatter – Tidy up the converted JSON before you commit it.
- JSON Validator – Confirm the output is valid JSON before wiring it into your app.
- JSON to Table – Preview the converted JSON as a table to sanity-check the shape.
Useful Resources
- W3C XML – The official home of the XML specification and related standards.
- MDN DOMParser – Documentation for the browser API that powers this converter.
- RFC 8259 – The IETF JSON specification — the target format for the conversion.
- JSON.org – Original JSON spec with railroad-style grammar diagrams.
- W3Schools XML Tutorial – Step-by-step XML introduction including XPath and XSD basics.
- Stack Overflow XML – Community answers for XML parsing and mapping edge cases.