Skip to content
DDevToolery

XML to JSON

Parse XML into JSON with control over attributes and typing.

Loading tool…

About this tool

Parses XML and emits the equivalent JSON structure, with attributes distinguishable from child elements by a prefix. The parser performs no DTD processing and resolves no external entities, so a document cannot make your browser fetch anything.

Limitations

  • External entity resolution is disabled, so documents relying on external DTDs will not expand.
  • An element appearing once becomes an object; appearing twice it becomes an array. Shape can therefore change with data.

Questions

What is the @_ in my keys?
It marks an attribute rather than a child element, since JSON has no way to distinguish the two. You can change the prefix or drop attributes entirely.
A single element became an object instead of an array.
XML gives no way to tell a one-element list from a single value, so the parser cannot know. If your consumer expects an array, normalise it after conversion.

Privacy

This page does its work in your browser. What you paste is processed by JavaScript running on your own device and is never sent to a DevToolery server — there is no server that could receive it. The page itself is a static file delivered by a CDN. See exactly what is stored.