XML to JSON Converter
Convert XML to JSON for free — paste XML or open a file (RSS, SVG, KML, GPX, config files) and get clean, readable JSON instantly. Attributes are kept with a prefix you choose, repeated elements become arrays, mixed text is kept as “#text”, and numbers and true/false can be converted to real JSON types. Errors in the XML are pointed out clearly.
100% private — everything runs in your browser. Conversion happens on your device; nothing is uploaded.
Attributes become keys with your chosen prefix, text next to child elements becomes “#text”, and repeated elements become arrays. Parsed with your browser’s built-in XML parser; nothing is uploaded.
How to convert XML to JSON
- Paste your XML or click Open file.
- Choose the attribute prefix, indent and type options.
- Read the JSON as you type.
- Copy it or download the .json file.
What you can use it for
- Use XML API responses and feeds in JavaScript apps
- Migrate legacy XML configs to JSON
- Inspect RSS, sitemap, KML and GPX files
- Prepare XML data for NoSQL databases
More free tools
Building for the web?
Format, minify, convert and generate code with our free, private developer tools.
See all free tools →Frequently asked questions
How are XML attributes converted?
Each attribute becomes a key with a prefix — by default “@”, so <book id="1"> becomes {"@id": 1}. You can switch the prefix to _ or -.
What happens to repeated elements?
Elements that appear more than once become a JSON array. Tick “Always use arrays” if you need every child as an array for a consistent structure.
Why is my XML invalid?
Common causes are an unclosed tag, an unescaped & (use &), or more than one root element. The error message shows what the parser found.
Is my data uploaded?
No. It's converted in your browser — nothing is sent to a server.
Which values become numbers or true/false?
With Convert numbers and true/false ticked, which is the default, a value that is exactly true or false in lowercase becomes a JSON boolean, and plain numbers such as 1992, -3.5 or 29.95 become JSON numbers. Values with leading zeros like 007 or 02134, integers longer than 15 digits, and forms such as 1e3, +5 or 1,000 stay strings. Attribute values follow the same rules. Untick the option to keep every value as a string.
What does the JSON output look like?
The result is one object named after the root element, such as {"catalog": {…}}. Inside each element, attributes come first, then child elements in the order they first appear. An element with only text becomes a plain value, an empty element becomes an empty string, and an element with both attributes and text keeps the text under "#text", for example {"@currency": "USD", "#text": 29.95}. The XML declaration and DOCTYPE are not included.
How are namespaced tags like dc:creator handled?
Element and attribute names are kept exactly as written, prefix included, so an RSS <dc:creator> becomes the key "dc:creator". Namespace declarations are treated like any other attribute: xmlns:dc becomes "@xmlns:dc", or "_xmlns:dc" with the _ prefix, with the namespace URL as its value. That keeps feeds, SVG and KML files readable while showing which namespace each key belongs to.
What happens to CDATA sections and entities such as &?
Text inside a CDATA section is kept as plain text, so <![CDATA[<b>bold</b>]]> becomes the string "<b>bold</b>". Escaped characters are decoded by the XML parser: & becomes &, < becomes <, and numeric references such as © become ©. Double quotes inside text are escaped as \" in the JSON, so the output stays valid. Comments and processing instructions are skipped.
Which indent options are there, and how do I save the JSON?
Choose 2 spaces (the default), 4 spaces, Tab or Minified under Indent; Minified puts the whole result on one line with no spaces. The JSON updates as you type or change an option, and a line and character count shows under the output. Click Copy to put it on your clipboard, or Download to save it as converted.json, which is created in your browser.
Do I need an account, and can I use the JSON commercially?
No account or sign-up is needed: open the page, paste or open your XML and the JSON appears. The tool adds nothing of its own to the output, so the JSON is your data in a new format, and you can use it in commercial projects with no credit to us. Whether you may reuse the data itself depends on where the XML came from, such as a third-party feed or API.
Can I convert the JSON back to XML?
Yes. Paste the JSON into our JSON to XML converter and pick the same attribute prefix: keys that start with it become attributes again, "#text" becomes element text, and arrays become repeated elements. With the default settings, the sample catalog converts back to the same XML. Numbers and true/false values are written back as plain text, so they look just as they did before.