XML to JSON
Converts XML into JSON for integrating with modern APIs.
Convert XML data to JSON format.
Steps and notes
What is XML to JSON?
JSON is the lingua franca of modern APIs, but plenty of systems still emit XML. This tool parses an XML document and projects it into JSON: elements become objects, repeated elements become arrays, and attributes and text are given distinct keys so neither is lost. The mapping is not unique — XML carries more structure than JSON in places (attributes, mixed content) — so the output uses a consistent convention (commonly attributes under an "@" key and text under "#text") that you can rely on when parsing it downstream.
- Paste the XML
- Get the JSON result
- Copy and use it
- XML attributes and text nodes are represented by different fields in JSON — check the output after converting
Frequently asked questions
- Where do XML attributes go in the JSON?
- This tool puts attributes under a dedicated key (typically @) and element text under another (typically #text), so <user id="1">Alice</user> becomes { "user": { "@id": "1", "#text": "Alice" } }. The exact key names follow the converter's convention — read one sample before trusting the shape in code.
- Why did my repeated tags become an array?
- JSON has real arrays; XML does not. When the same child element appears more than once, the converter groups them into an array so order and multiplicity are preserved. A single occurrence stays a single object unless the schema marks it as a list.
- How do I convert back to XML?
- Use the JSON-to-XML tool. Keep in mind the round trip is not perfectly symmetric: attributes that became @ keys must be re-special-cased, and any typing XML lost (everything is text) will not magically return.
Category: Converter
JSON format conversion workflow
JSON to YAML converter → YAML to JSON converter → JSON to XML → XML to JSON → JSON to TOML → TOML to JSON