XML to JSON Converter
Data ConversionParse XML into a clean JSON structure, with attributes and repeated elements handled properly.
Runs entirely in your browser — nothing is uploaded
Features
- Attributes become @-prefixed keys; text-only leaves become their value.
- Repeated elements become arrays automatically.
- Force chosen elements to always be arrays, so the shape is stable.
- Strips namespace prefixes, or keeps them.
- Names the line and column when the XML is malformed.
How to use the XML to JSON Converter
- 1Paste your XML, or drop an .xml file.
- 2Adjust the attribute prefix and type detection if you need to.
- 3Copy the JSON or download it.
Frequently asked questions
Why does one record convert differently from two?
Repeated elements become an array, so a document with two <book> elements gives a list while one gives a single object — a real trap when code written against a two-record sample meets a one-record response. Put the element name in “Always an array” to pin the shape.
How are attributes represented?
As keys prefixed with @, so <price currency="INR">1499</price> becomes {"@currency": "INR", "#text": 1499}. An element with no attributes and no children is simply its own text value, because wrapping every leaf in {"#text": …} would double the size of the document for nothing.
Is it safe to paste XML from an untrusted source?
Yes. Parsing uses the browser’s own XML parser, which does not resolve external entities in application/xml — so a document carrying a DTD cannot read your files or make network requests. Comments and processing instructions carry no data and are dropped.
What happens to namespaces?
By default the prefix is stripped, so <ns:title> becomes "title" — which is almost always what you want when the JSON feeds code. Turn the option off to keep the prefixed names.