English

XML to JSON — Attributes, Arrays and Unicode

Convert XML attributes to @keys and repeated elements to arrays

Runs in your browser · nothing is uploaded

Attributes use @name; mixed text uses #text. Repeated sibling names become arrays. Values remain strings. Exact mixed-content order is not preserved. DTDs are not supported.

Result

How to use

  1. Paste an XML document with one root element.
  2. Inspect the attribute keys and repeated-element arrays.
  3. Copy the resulting JSON into your application or analysis tool.

Mapping rules

The root tag is retained as the outer JSON key. Attributes use an @ prefix, such as @id. Repeated child names under one parent become arrays. An element without attributes or child elements becomes a string, and an empty element becomes an empty string. CDATA and standard XML character references are read as text.

When an element contains children, its direct text is collected in #text. Whitespace-only formatting around children is omitted. This does not preserve the relative order of text and nested elements in mixed content. Comments and processing instructions are omitted. Namespace prefixes and xmlns attributes retain their original names, without namespace-aware restructuring.

Examples

<r><item>한글</item><item>中文😀</item></r> produces an item array under r. <price currency="KRW">001</price> produces @currency with KRW and #text with the string 001.

Validation and limits

Unclosed tags, multiple roots and unknown entities produce an error. DTD and entity declarations are not supported. Input is limited to one million characters and 64 nesting levels. This mapping is convenient for data inspection, but it is not a lossless XML serialization. Results remain inert text, and all conversion happens locally in your browser.

FAQ

Are numeric-looking values converted to numbers?

No. Element text and attribute values stay strings, preserving leading zeros in values such as 001.

Is mixed-content order preserved?

No. Direct text is collected into #text. The relative positions of that text and child elements are not retained.

Can it load DTDs or external entities?

No. DOCTYPE and ENTITY declarations are rejected. The tool does not fetch external documents or expand declared entities.

Missing a tool?