XML to JSON converter
Convert XML to JSON or back, in the page.
- Runs in your browser — your text is never sent anywhere
- No sign-up, no quotas, free to use as often as you like
How it works
XML and JSON describe the same kind of structured data in incompatible ways, and plenty of systems speak only one. Converting between them is a constant integration chore, usually done with payloads that contain things which should not be pasted into a stranger's server.
Attributes become @ fields
JSON has no concept of attributes, so an XML attribute becomes a field prefixed with @, and text content sitting alongside child elements becomes #text. That convention is widely used and, importantly, reversible: converting back produces the attributes again rather than stray elements.
Repeated elements become arrays
Two or more sibling elements with the same name become a JSON array. One element stays a single value — which means a list that happens to contain one item converts differently from the same list with two. That ambiguity is inherent to XML, not a choice made here, and it is worth knowing if you are generating code from the result.
Going the other way
JSON keys become element names, with invalid characters replaced so the XML stays well-formed. Keys beginning with @ become attributes and #text becomes text content, so a document converted to JSON and back comes out recognisably the same.
It validates first
XML is parsed by your browser's own parser and JSON by its JSON parser, so malformed input is reported with a real message rather than producing mangled output.
XML to JSON converter — questions
What happens to XML attributes?
They become fields prefixed with @, which converts back to attributes correctly.
Why is a single item not an array?
XML cannot distinguish a one-item list from a single element. That ambiguity is in the format itself.
Can it convert JSON back to XML?
Yes. Paste JSON and it converts the other way.
Is my data uploaded?
No. Both conversions run in your browser.