About the XML to JSON Converter

What does this tool do?

XML and JSON are two of the most common ways to move structured data around, but they look nothing alike. XML wraps everything in angle-bracket tags; JSON uses tidy nested objects and arrays. This converter reads valid XML — a config file, an API response, an RSS feed, a sitemap — and rewrites it as clean, properly nested JSON you can drop straight into JavaScript, Python, or any modern app.

It converts as you type. Paste XML on the left and the JSON appears on the right the instant the markup is valid, with a status badge telling you whether the input parsed. You control how attributes are named, whether numbers and booleans are converted from text, and how the output is indented. The whole thing runs on your browser's built-in XML parser, so there's no upload, no waiting, and no third-party service touching your data — it even works offline once the page has loaded.

How to Use This Tool

  1. Add your XML. Type or paste it into the left editor, drag and drop a .xml file onto it, or use Open file. Click Example to load a sample and see the shape of the output.
  2. Set the options. Toggle whether to include attributes and whether to parse numbers and booleans, choose an attribute prefix (@_, @, $, or none), and pick the indentation — tabs, spaces, or minified.
  3. Read the result. Valid XML converts immediately and the JSON shows in the right editor. If something is off, the status badge points to the parse error so you can fix it.
  4. Take the JSON. Copy it to your clipboard or download it as a .json file.

Common Use Cases

Converting XML to JSON comes up constantly once you start wiring systems together:

  • Modernizing an API: Turn a legacy SOAP or XML response into JSON that a JavaScript front-end can consume without an XML parser.
  • Reading config and data files: Convert an XML config, an Android strings.xml, or an export file into JSON for a tool that prefers it.
  • Working with feeds: Reshape an RSS or Atom feed into JSON so it's easier to map over and render.
  • Inspecting structure: JSON's nesting often makes the shape of a document clearer at a glance than the equivalent XML.
  • Seeding tests and mocks: Grab a chunk of real XML, convert it, and use the JSON as fixture data.

Need to go further? Tidy the result in our JSON Viewer, or inspect raw markup with the XML Viewer.

Frequently Asked Questions

How are XML attributes shown in the JSON?

By default, attributes are kept and given an @_ prefix so they don't clash with child elements — an attribute like id="b1" becomes "@_id": "b1". You can change that prefix to @, $, or nothing at all, or switch attributes off entirely if you only care about the element content.

Why did a repeated tag turn into an array?

When the same tag appears more than once inside its parent — several <book> elements, for instance — there's no other faithful way to represent them in JSON, so they become an array of objects. A tag that appears only once stays a single object. This is the standard, lossless way XML-to-JSON converters handle repetition.

What does "Parse numbers & booleans" do?

XML stores everything as text, so <year>1999</year> is technically the string "1999". With this option on, values that look like a number or true/false are converted to real JSON numbers and booleans. We're careful with edge cases — a value like 007 stays a string so it isn't silently changed to 7. Turn the option off to keep every value as a string.

My XML shows a parse error — why?

The converter needs well-formed XML. The usual culprits are a missing or duplicate root element, an unclosed tag, mismatched casing (<Item>…</item>), or a stray & that should be written as &amp;. The status badge shows the parser's message to help you find it. Fix the markup and the JSON updates on its own.

Is my data sent to a server?

No. The conversion uses your browser's native XML parser and runs entirely on your device. Nothing you paste is uploaded, stored, or logged, which makes the tool safe for private or internal data and means it keeps working without a connection.

Can I convert the JSON back into XML?

This tool only goes one way, XML to JSON. The conversion keeps your content, attributes, and structure, but JSON has no direct equivalent for a few XML features like comments, processing instructions, or namespace declarations, so a round trip won't always be byte-for-byte identical.