XML to JSON conversion
Convert XML to JSON for APIs and configs
APIs and configuration systems increasingly expect JSON, but legacy services still return XML. The XML formatter now converts XML to a JSON structure locally, mapping elements, attributes, and text in a predictable way.
Convert in four steps
The same tool formats XML or converts it to JSON.
Open the formatter
Load the XML formatter in your browser.
Paste the XML
Paste the XML document or open a local file.
Choose Convert to JSON
Switch the conversion option from Format to JSON.
Copy the result
Copy the JSON into your code or configuration.
How the structure is mapped
Each element becomes an object. Attributes are prefixed with @, child elements become properties, repeated children become arrays, and text content is kept under #text when mixed with children.
This mapping is deterministic, so the same XML always produces the same JSON, which makes it safe to script.
Where XML to JSON gets tricky
- Repeated elements that need to become arrays
- Attributes mixed with child elements
- Mixed text and element content
Best practices
- Validate the XML before converting
- Check repeated elements become arrays
- Validate the JSON with the JSON formatter after conversion
Frequently asked questions
How are repeated elements handled?
Repeated child elements become arrays, so a list of items stays a list in JSON.
What happens to attributes?
Attributes are kept and prefixed with @, for example @id, so they do not collide with child element names.
Can I convert back to XML?
This tool converts XML to JSON. The JSON formatter handles JSON formatting and validation.
Is my XML uploaded?
No. Everything runs locally in your browser.
Your data stays local
Conversion runs in your browser. The XML and the JSON never leave your device.
Open XML Formatter