Convert XML to JSON

Paste XML to convert it to pretty-printed JSON in this tab. Elements become objects, repeated tags become arrays, and attributes become keys prefixed with @_. Comments and the XML declaration drop because JSON has no syntax for them. Use it for SOAP, RSS and Maven POMs. Nothing is uploaded.

JSON
XML
Converted on this deviceNothing leaves this tab

Runs in this tab · nothing is uploaded · Verify in 10 seconds →

What this does

XML → JSON parses the document in this tab and emits pretty-printed JSON. Elements become objects, repeated sibling tags become arrays, attributes become keys prefixed with @_, and text nodes become values. The sample below is already converted so you can see the mapping.

The @_ convention is the de-facto interchange used by fast-xml-parser: <book id="bk101"> becomes {"book":{"@_id":"bk101",…}}. A round trip XML→JSON→XML can drop comments, CDATA and the XML declaration because JSON has no syntax for them, and a single child cannot be told apart from a one-item list.

When it goes wrong

If conversion fails, the status names the first well-formedness error with line and column. Fix the XML first (unclosed tag, raw &, two roots). If the JSON looks “too nested”, the source used wrapper elements for lists; that is faithful, not a bug.

When to use this

Convert SOAP responses, RSS, Maven POMs and Android manifests into JSON fixtures for tests and APIs that no longer speak XML.

This page is a focused view of theJSON ↔ XML Converter, which has the full set of options.

Frequently asked questions

How are XML attributes represented in JSON?

As keys prefixed with @_. <book id="bk101"> becomes {"@_id":"bk101"} on the book object.

Is XML → JSON lossless?

Not always. Comments, processing instructions, CDATA wrappers and the XML declaration drop because JSON has no equivalent.

Does this upload my XML?

No. Conversion runs in this tab.

What happens to repeated elements?

Sibling elements with the same name become a JSON array, in document order.

Can I go back to XML?

Yes. Use JSON → XML on the same tool. @_ keys become attributes again.

Why did a number stay a string?

Text that looks numeric may still be emitted as a string or coerced to a number depending on the parser. Check the JSON before treating it as typed data.