XML to JSON Converter
Convert XML to JSON in the browser with the usual mapping — attributes as @name, text as #text, repeated elements as arrays — typed values, always-array names.
Pretty-printed JSON, counts of elements, attributes and arrays, and explicit notes on what the mapping loses: mixed content order, comments, declarations and the shape change when a child repeats.
Example: <book id="1"><title>A</title><tags><tag>x</tag><tag>y</tag></tags></book> becomes {"book":{"@id":"1","title":"A","tags":{"tag":["x","y"]}}}; typed, <m>12.5</m> is a number, 007 a string.
The usual mapping,
with its losses declared.
How elements, attributes and text become JSON, what typing does, and what the mapping cannot keep.
Mapping
Each element becomes an object: attributes as @name (prefix configurable), child elements as members, text as #text — or, when an element holds only text, just the string. A child name that repeats becomes an array; a name you list under "always arrays" is an array even when it appears once, which keeps the shape stable across documents.
Typed values
With typing on, numeric text becomes a number (leading-zero values such as 007 stay strings), true/false become booleans and empty elements become null. Off, everything is a string — the safer default for IDs and postcodes.
What is lost
Comments, processing instructions and the XML declaration are dropped; namespaces stay in the names; mixed content keeps its text under #text but loses where it sat among the children; the order between different child names is not preserved by JSON objects. The counts show how often each case occurred. Nothing leaves the browser; the same four anonymous usage counts as the rest of the site apply.
SOURCES
- Common XML→JSON convention (attributes prefixed, text under a reserved key, repeated children to arrays — as in xml2js / xml-js); parsing by the in-house XML Formatter parser
Last reviewed 20 September 2026. How results are checked: How we verify.