XML to JSON Converter
Paste XML or open a file and watch it turn into readable JSON instantly, entirely on your device.
Options
Conversion runs entirely in your browser — your XML is never uploaded.
How it works
- Paste your XML into the input box, or open an .xml file from your computer.
- Adjust the options if needed: keep or drop attributes, and choose how text-only elements are represented.
- Copy the pretty-printed JSON to your clipboard or download it as a .json file.
Frequently asked questions
- How are XML attributes represented in the JSON output?
- Each attribute becomes a property on its element’s object, prefixed with @ to keep it distinct from child elements — so <book id="1"> produces "@id": "1". If you do not need attributes, turn off the preserve-attributes option and they are dropped entirely, which gives you a flatter, cleaner result.
- When does the converter create a JSON array?
- Whenever an element contains two or more children with the same tag name, those siblings are grouped into an array under that name. A single child stays a plain object or string, which mirrors how most XML-to-JSON mappings (such as the common Parker and BadgerFish conventions) behave.
- Are numbers and booleans converted, or does everything stay a string?
- Everything stays a string. XML has no type system — <price>9.99</price> is just character data — so guessing types can corrupt values like ZIP codes with leading zeros or version numbers. Keeping strings preserves the data exactly; you can cast values in your own code where you know the intended type.
- Does it support namespaces and CDATA sections?
- Yes. Namespaced tags keep their prefix in the key, so <soap:Body> becomes "soap:Body", and xmlns declarations appear as ordinary @-prefixed attributes. CDATA sections are treated as regular text content, so embedded HTML or code inside CDATA comes through unescaped as a string value.
- Is my XML uploaded to a server?
- No. Parsing and conversion run entirely in your browser using the built-in DOMParser, so the document never leaves your device. That makes the tool safe for configuration files, API responses, and exports that contain private data, and it keeps conversion instant even for large files.
About this tool
This tool converts XML documents into JSON so you can work with the data in JavaScript, Python, jq, or any modern API pipeline. Paste markup directly or open an .xml file, and the JSON output updates live as you type. The result is pretty-printed with two-space indentation, ready to copy into a test fixture, a config file, or a REST client.
Conversion happens entirely in your browser. The document is parsed with the DOMParser built into every modern browser — the same engine that renders web pages — and the resulting element tree is walked recursively: elements become objects, attributes become @-prefixed properties, repeated sibling elements are collected into arrays, and text content becomes string values. Because no server is involved, nothing is uploaded, there are no size quotas, and sensitive documents such as invoices, medical exports, or SOAP responses stay on your machine.
Typical uses include inspecting SOAP and RSS payloads in a readable form, migrating legacy XML configuration to JSON, turning sitemap.xml or an Atom feed into data you can filter with jq, and building test fixtures from real API responses. Since the parser reports the exact line and reason for malformed markup, the tool also works as a quick XML validity checker: paste a document and any well-formedness error is shown immediately instead of a half-converted result.
Two options control the mapping. Preserve attributes keeps or drops @-prefixed properties — dropping them is useful when attributes only carry schema noise. Compact text nodes decides whether an element containing only text becomes a plain string (compact, easiest to read) or an object with a #text property (uniform, easier to process mechanically when some siblings have attributes and others do not). Whichever you choose, values are kept as strings so leading zeros, IDs, and version numbers survive untouched.