XML → JSON
XML Input
Loading editor…
JSON Output
Loading editor…

XML to JSON Converter

Paste any XML document and get a clean, structured JSON output instantly. Nested elements, attributes, and repeated tags are all handled correctly. No login, no data upload.

Real-time
JSON output updates as you type or paste.
Nested support
Deeply nested XML elements are preserved in the JSON structure.
Attributes
XML attributes are included using the @_ prefix convention.
Client-side
No data is uploaded. Everything runs in your browser.

How XML to JSON Conversion Works

XML uses nested tags and attributes; JSON uses objects and arrays. The mapping is straightforward: each element becomes a key, nested elements become nested objects, repeated elements at the same level become an array, and attributes are preserved with an @_ prefix.

<user id="1">
  <name>Alice</name>
  <role>admin</role>
</user>
{
  "user": {
    "@_id": "1",
    "name": "Alice",
    "role": "admin"
  }
}

Attributes, Arrays, and Mixed Content

Attributes are kept using the @_ prefix — the convention used by most XML-to-JSON libraries. It puts attributes alongside child elements in the same object without key collisions.

Repeated tags at the same level collapse into a JSON array automatically:

<items>
  <item>apple</item>
  <item>banana</item>
</items>

Output: { "items": { "item": ["apple", "banana"] } } — not two separate keys.

Mixed content (a tag with both text and child elements) moves the text to a #text key alongside the child keys. Self-closing tags like <br /> appear as an empty string or just their attributes.

When to Convert XML to JSON

Banking, government, ERP, and insurance systems frequently expose SOAP services that only produce XML. Web syndication formats — RSS and Atom — are XML. JIRA data exports, Maven POMs, and many legacy configuration formats (Ant, Spring XML) are also XML. JSON is the expected input for modern REST APIs, JavaScript frontends, and NoSQL databases.

Converting XML to JSON is typically a one-off task when consuming a legacy feed or migrating data out of an older system. Doing it here avoids writing a parser by hand.

XML vs JSON — Key Differences

FeatureXMLJSON
AttributesYes — <tag attr="val">No native equivalent
CommentsYes — <!-- comment -->Not supported
NamespacesYes — xmlns:prefixNo
Mixed contentYes — text + child elementsNo
Data typesStrings only (schema needed for types)Native numbers, booleans, null
VerbosityHigh — opening and closing tagsLow
Array notationImplicit (repeated tags)Explicit []

Frequently Asked Questions

How are XML attributes handled?

Attributes are included in the JSON output with an @_ prefix. For example, <item id='1'> becomes { "@_id": "1" } alongside the element's child properties. This is the standard convention used by fast-xml-parser and most XML-to-JSON libraries.

What happens with repeated XML tags?

If the same tag appears multiple times at the same level (e.g. multiple <item> elements), they are automatically converted to a JSON array. A single occurrence stays as an object; two or more become an array.

Is the XML declaration (<?xml ...?>) included in the output?

No — the XML declaration is stripped from the output since it has no JSON equivalent. Only the document's element content is converted.

Are XML namespaces supported?

Namespace prefixes are preserved as part of the key name (e.g. ns:item becomes the key "ns:item"). Namespace declarations (xmlns attributes) are treated like regular attributes with the @_ prefix.

What happens to XML comments?

XML comments (<!-- ... -->) are ignored — they have no JSON equivalent and are not included in the output.

Can I convert SOAP responses or RSS feeds with this tool?

Yes. Both are standard XML documents and are fully supported. SOAP envelopes and RSS/Atom feeds often have deeply nested elements and attributes — all of which are handled correctly.

Is my XML data uploaded anywhere?

No. All conversion happens locally in your browser using fast-xml-parser. Your data never leaves your device — safe to use with internal API responses or confidential XML exports.