JSON1 / XML to JSON
XML to JSON
Convert XML to formatted JSON. Attributes become @name keys, repeated elements collapse into arrays, and mixed text lands under #text.
Processed locally·Your data never leaves your device
InputXML
ReadyOutputJSON
Converted output appears here as you type.
Good to know
- XML has no type system, so values are guessed: "10001" becomes the number 10001 and an empty element becomes null. Round-tripping JSON through XML will not always return the original types.
About this tool
Turning XML into JSON is usually about getting a legacy or third-party payload into a shape modern code can work with. The mapping has to invent conventions, because XML distinguishes things JSON does not.
Attributes become keys prefixed with @, repeated sibling elements collapse into an array, and text mixed in alongside child elements lands under #text. Those three rules cover the cases where a naive conversion would silently drop data.
- Why did my postcode 02134 become the number 2134?
- XML has no type system — everything is text — so values have to be guessed. Anything that looks numeric becomes a number and an empty element becomes null. Round-tripping JSON through XML and back will not always return the original types, and this is the step where that happens.
- Where did my attributes go?
- Nowhere. An attribute
id="7"becomes the key@id. The prefix keeps it from colliding with a child element that happens to be namedidtoo.