XML to JSON Converter — Attributes, Namespaces & SOAP
Convert XML documents to JSON format with our free browser-based converter. The tool handles XML attributes (converted to @attribute keys), nested elements, CDATA sections, and namespaces.
Paste XML data and get a clean JSON representation ready for use in modern APIs and applications. Runs entirely inside the browser.
XML carries structure that JSON has no direct equivalent for, so the mapping is stated up front: attributes become keys prefixed with @, text content of a mixed element goes into #text, repeated sibling elements collapse into an array, and CDATA sections are unwrapped to their contents. Namespaces are kept on the key rather than thrown away, so a document using two schemas does not silently lose the distinction. The result is ordinary JSON you can feed straight into JavaScript, a JSON column in Postgres, or any modern API client.
How to use XML to JSON
- Paste your XML markup into the input field.
- Adjust configuration, like attribute prefix modifiers.
- Click Convert to generate the equivalent JSON object.
- Click the button to copy it safely to your clipboard.
Features
- Handle XML attributes, nested elements, CDATA — Full XML support.
- XML syntax validation with error messages — Spots invalid XML automatically.
- Pretty-print JSON output — Clean, readable output format.
- Support for large XML documents — Handles complex structures.
- Configurable attribute prefix (@, _, $) — Customize attribute notation.
- 100% client-side processing — Safe to use for personal datasets.
Frequently Asked Questions
How are XML attributes represented in JSON?
Because JSON does not natively support "attributes" separate from key-value pairs, our tool prepends specific characters (like @) to attribute names so they don't collide with child elements.
Does it support exceptionally large XML files?
Yes, because there are no upload payload limits. However, generating enormous JSON trees might momentarily freeze older browsers or consume more temporary memory.
Can I decode SOAP XML envelopes?
Absolutely. SOAP APIs return standard XML, which the tool will smoothly translate into nested JSON parameters spanning headers and the underlying response body payload.
Why does a single child element become an object but two become an array?
Because XML has no way to say "this is a list of one". A converter can only see what is there. If your downstream code needs an array every time, normalise after conversion — check whether the value is an array and wrap it if not. This is the classic gotcha when an XML feed happens to return one item that day.
Are namespaces preserved?
Yes. Prefixed element and attribute names keep their prefix in the JSON key rather than being flattened away. That matters for documents that combine schemas, such as a sitemap with image or video extensions, where two different elements can otherwise collapse onto the same key.