XML to JSON
ConverterConvert an XML document to JSON via DOMParser with attribute and namespace support for modernizing legacy API responses and configuration file processing.
Related Tools
About XML to JSON
Through SOAP endpoints, RSS/Atom feeds, Android layout files, and legacy backend APIs, XML still shows up constantly — yet browsers, modern services, and frontend frameworks are far more comfortable with JSON. This tool parses XML and converts it to JSON locally in your browser, sensibly handling attributes, text nodes, namespaces, comments, and processing instructions, with options to keep or drop the namespace prefix and to preserve CDATA. Repeated same-name elements are gathered into arrays while single occurrences stay as plain objects, so the same schema can produce different shapes; keep that in mind on the consuming side. You can customize the attribute marker (default @) and the text-node key (default #text). Because everything runs on your machine, internal or sensitive messages are never uploaded. For example, <user><id>1</id></user> becomes {"user":{"id":"1"}} with attributes and children mapped to object fields, giving a clean starting point for client code.
How to Use
- Open the XML to JSON tool
- Select the source and target formats
- Adjust the output options as needed
- Click the Convert button; results appear in real time
- Copy or export the result
Use Cases
- Consume SOAP responses — Convert XML from a SOAP endpoint to JSON so the frontend can use JSON.parse directly.
- Parse RSS/Atom — Convert feed XML to JSON to easily extract title, link, and date fields.
- Migrate legacy systems — Convert legacy XML data to JSON for import into new JSON-based services.
- Read configs — Convert XML config to JSON to avoid bundling a heavy XML parser in the frontend.
- Analyze data — After converting to JSON, query and aggregate with jq or JSONPath.
- Transform SVG data — Convert SVG XML markup to JSON for dynamic rendering in React or Vue components.
- Parse EDI/XML messages — Convert EDI-standard XML to JSON objects for processing in modern data pipelines.
FAQ
Are XML attributes lost?
No. Attributes typically map to keys with a prefix (e.g. @ or $) to distinguish them from child elements, keeping all information.
How are repeated elements handled?
Repeated same-name children become a JSON array; elements appearing once become a plain object — as expected, so the consumer should handle both shapes.
What about namespaces?
Namespace prefixes are usually kept in key names (e.g. ns:tag). Clean them up manually after conversion, or use the strip-prefix option, if not needed.
What about mixed content (text + children)?
When an element has both text and child nodes, the text goes into a dedicated key (e.g. #text) while children map normally.
Which XML constructs are dropped?
Comments, processing instructions, and the XML declaration can be discarded by default; toggle them on if you must preserve narrative comments or PIs.
Can I get JSON back to XML?
Use our JSON to XML tool; note the attribute/marker conventions you configured here so a round-trip stays predictable.