XML to JSON Converter

Convert XML to JSON and back, with the attribute and array conventions spelled out. 100% free, no signup. Everything runs in your browser.

100% free No sign-up Private by design Works on any device
XML to JSON ConverterRuns locally

Loading the tool…

XML never went away. It is still in bank feeds, government data, RSS, sitemaps, invoices, SOAP endpoints, configuration files and half the exports older business software produces. JSON is what the rest of the modern world speaks. I built this because I spent an afternoon reading a supplier's XML feed by eye in a browser tab, trying to work out its shape, when what I wanted was to see it as JSON so my brain could parse it in seconds.

Paste or drop XML and get pretty printed JSON, or flip the direction toggle and turn JSON back into XML. Output is indented so it can be read rather than merely stored, with copy and download buttons for both directions. Everything runs in your browser, which matters because the things people convert are API payloads, order files and customer records rather than tidy textbook examples. If the JSON side needs checking afterwards, the JSON formatter picks up where this leaves off.

How to use

  1. Choose your direction with the toggle: XML to JSON, or JSON to XML.
  2. Paste your XML or JSON into the input box, or drop a file onto it.
  3. The converted result appears in the output box, indented and ready to read.
  4. Check how attributes were handled. In JSON output they appear as keys with an at sign in front of the name.
  5. Fix any error the tool reports. Malformed input is usually an unclosed tag or a stray comma.
  6. Press copy to take the result, or download to save it as a file.
  7. Switch the direction and paste the result back in if you want to see how it converts the other way.

Why use our xml to json converter?

The direction toggle earns its place more than I expected. Going from XML to JSON is the usual errand, but the return trip comes up constantly when an old system will only accept XML and everything you have is JSON. Both in one place beats hunting for a second site with different conventions. If your data started life in a spreadsheet rather than a feed, the CSV to JSON converter is the better door.

Now the honest part, which is why this page carries a long explanation instead of just two boxes. XML and JSON do not map onto each other perfectly, and any tool implying otherwise is hiding something. XML has attributes, JSON does not. XML lets an element contain text and child elements at once, JSON has nowhere to put that. XML has no idea what an array is, so one order line and five order lines look structurally different. Every converter invents a convention, and the useful thing a tool can do is tell you which one it uses.

Here is the convention. Attributes become keys prefixed with an at sign, so a tag with an id attribute produces a key called at id alongside the element's other content. Element text becomes the value directly when the element has nothing else in it. Repeated sibling elements become an array. That last rule carries the classic trap and it is the part I got wrong first: when a list contains exactly one item, nothing signals that it was ever a list, so it converts to a single object rather than an array of one. Code written against a two item sample then breaks on a one item response.

A few more things worth knowing before you trust a round trip. Comments and processing instructions do not survive into JSON, because JSON has no concept of either. Namespace prefixes are kept as part of the key name, which stays readable but does not preserve the formal declarations described in the W3C XML specification. Mixed content, meaning text interleaved with child tags, is the one shape that cannot be represented cleanly, and it shows up in document style XML far more than in data style XML.

Everything happens in your browser and nothing is uploaded. Developers paste production payloads into converters all day long, and those payloads contain customer names, addresses, order values and sometimes tokens. Pasting that into a website that processes it server side is a data transfer you could not easily justify in a security review. Here the text never leaves the tab.

Who is this tool for?

The most common job is exploring an unfamiliar feed. You have a supplier catalog, a bank statement export or a government data file in XML, and you want its shape before writing a line of code against it. Reading it as indented JSON is faster for most people, and the structure becomes obvious in a way angle brackets never quite manage.

Integration work is the other big one. A modern app speaks JSON, a legacy system speaks XML, and somebody has to sit in the middle. Building a sample payload for the old system by converting a known good JSON object beats writing XML by hand and discovering the schema complaints one at a time.

Content and marketing teams hit it through RSS and sitemaps. Turning a feed into JSON makes it trivial to see which fields are actually populated across a hundred items, and pushing that into a spreadsheet is one more step with the JSON to CSV converter. Analysts use the same route to rescue data out of old exports, since accounting and point of sale software from the 2000s all speaks XML.

Frequently asked questions

Is my data uploaded when I convert it?

No. The conversion runs inside your browser tab and nothing is sent to a server, so production payloads are safe to paste.

How are XML attributes handled?

They become keys prefixed with an at sign, which keeps them distinguishable from child elements sharing the same name. That prefix is the standard convention for this problem.

Why did my list of one item not become an array?

Because XML cannot express the difference between a list of one and a single element. Repeated siblings become an array, but a lone element looks like a plain object. Write your code to handle both shapes, since the feed will eventually send each.

Will XML to JSON and back give me my original file?

For straightforward data files it gives an equivalent document, but not a character for character copy: comments are dropped, whitespace and attribute order may change, and mixed content gets restructured.

Does it handle namespaces?

Prefixed names are preserved as part of the key, so you can see which namespace an element came from. The formal declarations are not reconstructed on the way back.

How large a file can it handle?

Comfortably large, but everything is parsed in memory in your browser, so a file of many megabytes will be slow on an older machine. Take a representative sample when you are only exploring the structure.

Why am I getting a parse error?

Almost always an unclosed tag, an unescaped ampersand or a stray comma in the JSON direction. Invisible characters from a copy and paste are another regular culprit, and the text cleaner strips those out.

Are numbers and booleans converted for me?

XML has no types, everything in it is text. Values arrive in JSON as they appeared in the document, so treat any conversion to numbers or booleans as a decision for your own code.

Related tools