XML → JSON

XML to JSON

XML to JSON maps XML element names to object keys, repeated elements to arrays, and attributes to @ keys. Use ordered nodes when mixed text must keep its original position.

Drop a file or paste below
Conversion options

Ready

XML attributes and repeated elements

For <item id="007">Note</item>, the compact result has @id: "007" and #text: "Note". Repeated children with the same qualified name become an array. A single child stays a single value. XML values stay strings, keeping identifiers such as 007 intact rather than coercing them into numbers.

Namespace names and mixed content

Qualified names such as p:item and attributes such as xmlns:p remain in the result. Compact objects group child names, so text interleaved around elements is not a reversible representation. Ordered nodes instead record element names, attributes and a sequence of text, CDATA and child nodes. Choose that form for mixed content such as paragraphs with inline emphasis.

XML parse errors

The input must be one well-formed XML document with a root element and matching closing tags. Bare ampersands need XML escaping. The converter reports parser errors instead of returning a partial result. XML comments are retained in ordered-node mode; compact objects focus on attributes, child elements and text.

Format references

XML 1.0 · JSON format

File content is read and converted in the browser. Conversion does not upload the source to a server.

Frequently asked questions

Are leading zeros preserved?

Yes. XML attribute and text values remain strings.

Are namespace prefixes removed?

No. Qualified element and attribute names are kept.