XML to JSON
Convert XML to JSON format. Uses the browser's DOMParser to parse XML and recursively build a JSON object — all in your browser, no upload, instant results.
About the XML to JSON Converter
This XML to JSON converter runs entirely in your browser. Paste XML into the box above and click Convert. The result appears as formatted JSON. Nothing is uploaded to a server — the conversion happens instantly with JavaScript on your device.
About the XML format
XML (eXtensible Markup Language) is a markup language that defines a set of rules for encoding documents. It uses tags to delimit data, supports attributes on elements, and can be nested arbitrarily. It is widely used for configuration, data exchange (SOAP, RSS), and document storage.
Conversion rules
- Elements — Each XML element becomes a JSON object property named after the tag.
- Attributes — Element attributes are collected under a
@attributesobject. - Text content — Pure text content of a leaf element becomes a JSON string value.
- Repeated tags — Multiple child elements with the same name are merged into a JSON array.
- Mixed content — When an element has both text and attributes, the text is stored under
#text. - CDATA — CDATA sections are treated as text content.
Common use cases
- Consuming XML APIs in JavaScript applications.
- Converting SOAP responses to JSON for easier processing.
- Migrating XML configuration files to JSON.
- Inspecting XML structures in a more compact form.
Frequently asked questions
Does this tool upload my XML? No. All conversion happens locally in your browser. Your data never leaves your device.
What happens to the XML declaration? The <?xml ...?> prolog is ignored. Only the document tree is converted.
Are comments preserved? No. XML comments (<!-- ... -->) are skipped during conversion.
Is there a size limit? The only limit is your browser's available memory. Even large XML files convert quickly.