XML to JSON
XML to JSON
Convert XML to JSON. Attributes become keys starting with @, and element text is stored under #text when an element also has children or attributes.
The XML to JSON Converter turns XML documents into clean, pretty-printed JSON that modern apps and APIs can use directly. Many feeds, invoices, and legacy systems still publish XML, while new code almost always prefers JSON. This tool bridges that gap in seconds, right in your browser.
The conversion rules are simple and stated up front. Attributes become JSON keys that start with @, so id="1" becomes "@id": "1". Child elements become keys with their element name, and repeated elements with the same name are gathered into an array, in document order. When an element holds both text and children or attributes, the text is kept under the #text key; a plain element with only text becomes a simple string.
The XML is parsed with the browser's own DOMParser, the same engine web pages use, and malformed XML is reported with the parser's own error instead of producing silent, wrong output. Nothing is uploaded; your document never leaves your device.
How to use
- Paste your XML into the box.
- Click Convert to JSON.
- Review the pretty-printed JSON result.
- Copy it, or download it as a .json file.
- If an error appears, fix the XML at the reported spot and convert again.
Frequently asked questions
Why do some keys start with @ or #?
JSON has no built-in idea of attributes or mixed text, so the converter marks them: @name for attributes and #text for an element's text when it sits alongside children or attributes. These markers make the conversion reversible and unambiguous.
What happens to repeated elements?
When the same element name appears more than once under one parent, the values are collected into a JSON array in the order they appear.
Are numbers converted to JSON numbers?
No. XML carries text only, so values stay strings. That is the safe, lossless choice; convert types in your own code where you know the meaning of each field.
Is my XML uploaded?
Never. Parsing and conversion happen locally in your browser.