01What is XML ↔ JSON Converter?
XML / JSON Converter turns XML into JSON and JSON back into XML, and the output updates as you type. There's no official standard for this mapping, so the tool sticks to one common convention and applies it the same way every time. Here are the XML to JSON rules. Attributes become keys with an @ prefix, so id="7" turns into "@id": "7". Child elements become keys named after the tag, and a tag that repeats becomes an array. An element with only text becomes a plain string, and an empty element becomes null. When an element has attributes or children and also text, the text goes under "#text". CDATA is treated as text, entities such as & and © are decoded, and comments and processing instructions are dropped. Text is trimmed. Every value stays a string because XML has no number type. Namespace prefixes stay part of the name, so you'll see keys like "atom:link". Before converting, the XML is checked for well-formedness under the W3C XML 1.0 rules. Mismatched or unclosed tags, duplicate attributes, an unescaped & or < and multiple root elements all give an error with a line number instead of a guessed result. A small example: <item id="7">Pen</item> becomes an "item" object holding "@id": "7" and "#text": "Pen". Paste <list><n>1</n><n>2</n></list> and "n" becomes an array of the strings "1" and "2". The JSON to XML direction reverses the same rules. The object needs exactly one top-level key, which becomes the root element, because an XML document has one root. Keys must be valid XML names. @ keys become attributes, #text becomes text, arrays repeat the element with the key's name and null becomes an empty element. Text and attribute values are escaped, so "<5 & up" comes out as <5 & up. The output starts with an XML declaration and uses two-space indentation. Now the honest limits. Mixed content such as <p>Hello <b>world</b> again</p> can't survive this convention. The text pieces are joined into #text and their position next to <b> is lost. A single <item> gives an object while two give an array, so your code must handle both shapes. A round trip is not perfect either. Numbers and booleans in your JSON become text in XML, and they come back as strings. The conversion runs as JavaScript in your open tab, so the XML or JSON you paste is never uploaded.
Integration developers who need to read a SOAP, RSS or legacy XML payload as JSON, or build a small XML request from a JSON object. The tool runs entirely in your browser, so your data never leaves your device.
02How to use XML ↔ JSON Converter
- Choose the XML → JSON or JSON → XML tab, or load one of the examples (RSS Feed, Config File, JSON to XML)
- Paste your XML or JSON into the input panel; the output updates as you type
- If an error appears, fix the line or key it names
- Copy the result, or download it as converted.json or converted.xml
03Worked examples
- Input:
XML to JSON: <item id="7">Pen</item> - Result:
{ "item": { "@id": "7", "#text": "Pen" } } - Attributes get an @ prefix and text sitting next to them goes under #text.
- Input:
XML to JSON: <list><n>1</n><n>2</n></list> - Result:
{ "list": { "n": [ "1", "2" ] } } - Repeated child elements become an array; values stay strings.
- Input:
XML to JSON: <p>Hello <b>world</b> again</p> - Result:
{ "p": { "b": "world", "#text": "Hello again" } } - Mixed content loses its order: the text pieces are joined into #text (note the double space) and <b> becomes a key.
- Input:
JSON to XML: {"root":{"tags":["a","b"]}} - Result:
<?xml version="1.0" encoding="UTF-8"?> <root> <tags>a</tags> <tags>b</tags> </root> - An array becomes repeated elements with the key's name, not a wrapper element.
- Input:
JSON to XML: {"price":"<5 & up"} - Result:
<?xml version="1.0" encoding="UTF-8"?> <price><5 & up</price> - Input:
JSON to XML: {"1bad":1} - Result:
"1bad" can't be used as an XML element or attribute name (names start with a letter or _ and contain no spaces)
04Common use cases
- Converting a SOAP or legacy XML API response to JSON for a JavaScript front end
- Reading an RSS feed or sitemap as JSON while prototyping
- Turning a .NET or Java XML config into JSON to inspect it with jq
- Generating a small XML payload from a JSON object for a test
- Checking how a vendor's XML order or invoice feed will look once your JSON-based service ingests it
- Spotting a mismatched closing tag in an XML file, since the error names the line
05Tips
- Use the @ prefix for attributes and #text for text in your JSON when converting to XML, the same names this tool produces
- A single <item> becomes an object but two become an array; code that reads the JSON should handle both shapes
- All values come out as strings, so convert numbers and booleans in your own code
- Wrap JSON with several top-level keys in one root key, because an XML document has exactly one root element
- Keys that start with a digit or contain spaces are rejected in JSON → XML, so rename them before converting
06Related concepts
XSLT, SAX parser, DOM, XML Schema.
Frequently Asked Questions
What is XML ↔ JSON Converter?
XML ↔ JSON Converter is a free, browser-based developer tool on AIDToolStack. Convert XML to JSON and back with attribute handling and pretty-printing It requires no installation or sign-up and works entirely in your browser.
Is XML ↔ JSON Converter free to use?
Yes. No sign-up, no fees and no usage cap.
Does XML ↔ JSON Converter store my data?
No. It runs in your browser; nothing is uploaded.