XML to JSON Converter
About this tool
Convert XML to JSON in your browser with the configuration knobs every other tool hides — pick the attribute prefix (@, _, $, @_, or none), control how namespaces are flattened, force tags to always become arrays, preserve CDATA, and verify the round-trip is lossless. Works equally well on SOAP responses, RSS feeds, Atom feeds, Maven POMs, sitemaps, and any XML you'd rather not paste into someone else's server. Bidirectional — flip the direction to convert JSON back to XML on the same screen.
Why use this XML to JSON converter?
How to convert XML to JSON in 4 steps
How it stacks up against other XML to JSON converters
| Feature | This tool | Most tools |
|---|---|---|
| Bidirectional XML ↔ JSON | ✓ same screen | separate page or one-way only |
| Configurable attribute prefix | ✓ 5 options | hardcoded @_ or _ |
| Namespace handling | ✓ preserve / strip / drop | usually preserved only |
| Force-array list | ✓ comma-sep | never exposed |
| Type coercion (numbers, booleans) | ✓ toggles | rarely exposed |
| CDATA preserve toggle | ✓ on by default | often dropped silently |
| Round-trip lossless check | ✓ one click | not available |
| 100% client-side privacy | ✓ verified | often server-side |
Same XML, different JSON shapes
<?xml version="1.0" encoding="UTF-8"?>
<library>
<book id="b1" lang="en">
<title>The Pragmatic Programmer</title>
<year>1999</year>
</book>
</library> {
"?xml": { "@version": "1.0", "@encoding": "UTF-8" },
"library": {
"book": {
"@id": "b1",
"@lang": "en",
"title": "The Pragmatic Programmer",
"year": 1999
}
}
} {
"library": {
"book": [
{
"@id": "b1",
"@lang": "en",
"title": "The Pragmatic Programmer",
"year": 1999
}
]
}
} Pro tips for XML to JSON conversion
Frequently asked questions
How does XML to JSON with attributes work?
By default, XML to JSON with attributes prefixes each attribute with @ in the JSON output. <code><book id="b1" lang="en"></code> becomes <code>{"@id": "b1", "@lang": "en"}</code>. You can change the prefix to <code>_</code>, <code>$</code>, <code>@_</code>, or convert XML to JSON without the @ prefix at all (merge attributes directly into the object). The 'no prefix' option is useful when you want clean JSON keys for XML that has no element/attribute name collisions — set it to none and <code><book id="b1">Title</book></code> becomes <code>{"id": "b1", "#text": "Title"}</code> instead of <code>{"@id": "b1", "#text": "Title"}</code>. This is the standout knob most online XML to JSON converters do not expose — they hardcode <code>@_</code> or <code>-</code> with no way to change it.
How do I convert XML namespace to JSON?
The XML namespace to JSON conversion has three modes. <strong>Preserve</strong> (default) keeps prefixed keys like <code>"dc:title"</code> and includes <code>xmlns</code> declarations as attributes. <strong>Strip prefix</strong> turns <code><dc:title></code> into <code>"title"</code> — cleaner JSON paths, drops the xmlns declarations. <strong>Drop</strong> removes the prefixed key entirely (including all <code><atom:link></code>, <code><dc:creator></code>, etc.) for cases where you only want the un-namespaced content. Strip is the right pick for SOAP responses and Atom feeds where the namespace is consistent but not interesting to your parser. Preserve is right when you actually need to distinguish <code>dc:title</code> from <code>atom:title</code>.
How do I force array XML to JSON conversion for single elements?
This is the #1 XML to JSON array gotcha. When <code><book></code> appears once, parsers create an object: <code>{"book": {...}}</code>. When it appears twice, the same parser creates an array: <code>{"book": [{...}, {...}]}</code>. Your downstream code then has to check <code>Array.isArray()</code> on every access — and crashes the moment your data goes from one item to two. The fix is the <strong>Force array</strong> option. Add <code>book</code> (or any tag name) to the comma-separated list, and the force array XML to JSON behaviour kicks in — that tag always becomes a JSON array, length 1, 2, 10, whatever, so the shape stays stable. This is the single most important XML to JSON setting for production code, and almost no other online converter exposes it.
How does XML CDATA convert to JSON?
XML CDATA sections (<code><![CDATA[…]]></code>) are preserved by default into a <code>#cdata</code> key on the parent object — so the XML CDATA to JSON conversion is non-destructive. SOAP fault details often wrap HTML in CDATA, and RSS feeds use CDATA for post bodies — without preservation, the HTML inside gets entity-encoded (<code>&lt;p&gt;</code>) and becomes painful to render. With Preserve CDATA on, <code><body><![CDATA[<p>Hello</p>]]></body></code> becomes <code>{"body": {"#cdata": "<p>Hello</p>"}}</code> — clean and easy to consume. Turn the toggle off if you want CDATA content merged into the text node instead.
Can I keep XML numbers as strings in the JSON output?
Yes — XML to JSON keep numbers as strings is one toggle away. Disable the 'Parse numbers' option. By default, <code><year>1999</year></code> becomes <code>{"year": 1999}</code> (numeric). With parsing off it becomes <code>{"year": "1999"}</code> (string). This matters for ZIP codes, phone numbers, IDs with leading zeros, version strings like <code>1.2.0</code>, and anywhere your downstream code expects strings. 'Parse booleans' works the same way — controls whether <code><active>true</active></code> becomes <code>true</code> or <code>"true"</code>.
Does this work for SOAP response to JSON, RSS to JSON, and Atom feed to JSON?
Yes — SOAP response to JSON, RSS to JSON, and Atom feed to JSON are the most common real-world XML to JSON conversions and this tool ships one-click examples for each. SOAP envelopes work cleanly with namespace handling set to 'Strip prefix' so <code><soap:Body></code> becomes <code>"Body"</code>. RSS to JSON works best with the <code>item</code> tag added to Force-array (so a single-item feed still produces an array). Atom feed to JSON wants <code>entry</code> in Force-array and <code>link</code> as well, plus 'Strip prefix' to clean up the <code>atom:</code> namespace. Maven POMs, Android manifests, sitemaps (<code>urlset</code> / <code>url</code>), and SVG files all parse cleanly with the defaults.
Is this a lossless XML to JSON round trip? Can I convert JSON back to XML?
Yes to both — this is a lossless XML to JSON round trip converter. Flip the direction button at the top to convert JSON back to XML — the same options panel applies (attribute prefix, text-node key, CDATA, indent). Turn on the <strong>Verify lossless</strong> toggle on the XML → JSON direction and the tool converts your XML to JSON, then back to XML, and compares the two. If the badge says 'Lossless', the round-trip is bit-exact (ignoring whitespace). If it says 'Lossy', something was dropped — usually XML comments, processing instructions other than <code><?xml></code>, or XML to JSON preserve order edge cases where strict element order matters. That tells you whether the JSON is a faithful representation or a one-way summary.
Are my XML and JSON sent to a server?
No. Conversion runs entirely in your browser — paste, drop, or load an example, all of it stays on your device. There is no network request involved, no telemetry on the conversion contents, and no analytics on what you paste. The site itself uses cookieless analytics (page views only) but the tool never reads or transmits your XML or JSON data. This matters for SOAP responses with customer PII, internal API payloads, and any XML you would not paste into a logged-in editor on someone else's server.