XML to JSON
Convert XML to JSON and back, keeping attributes and collapsing repeated elements into arrays.
Convert Between XML and JSON
XML and JSON do not map onto each other cleanly, and any converter has to make decisions. XML distinguishes attributes from child elements; JSON has only keys. XML allows repeated sibling elements; JSON objects need arrays for that. Pretending otherwise is how converters silently lose data.
This converter states its conventions plainly: attributes are prefixed, text content lands in a dedicated key, and repeated elements become arrays. Because those rules are consistent, the conversion round-trips — JSON produced here converts back to equivalent XML.
Key features
- Both directions — XML to JSON and JSON back to XML, using the same conventions each way.
- Attributes preserved — carried into prefixed keys rather than discarded, which many converters quietly do. One tick drops them if you would rather have clean data.
- Repeated elements become arrays — automatically, so a list of three items is a three-element array.
- CDATA and entities handled — unescaped properly instead of being left as literal markup.
- Real parse errors — malformed XML is reported with a reason rather than silently producing an empty object.
This tool runs entirely inside your browser using native Web APIs. Your files and text are never uploaded to a server, never logged and never shared with third parties.
How to use: XML to JSON
- Paste your XML
A document, an RSS feed, a SOAP envelope, a config file — anything well-formed. The Sample button loads one if you just want to see the shape. - Pick the direction
XML → JSON, or JSON → XML if you are going the other way. - Decide about attributes
Keep them and they arrive as prefixed keys; untick and only element content survives. - Copy or download
Formatted output, ready to paste, or saved straight to a file.
Technical specifications
| Processing location | Entirely in your browser — no server round trip |
|---|---|
| Data uploaded | None. Files and text never leave your device |
| Price | Free — no account, no trial, no usage cap |
| Category | Developer |
| Works offline | Yes, once the page has loaded |
| Browser support | Chrome 90+, Edge 90+, Firefox 90+, Safari 15+ |
| Interface languages | English, 中文, हिन्दी, Español, العربية |
Frequently asked questions
How are attributes represented?
As keys with an `@` prefix. An element <code><item id="3"></code> becomes an object carrying an <code>@id</code> key alongside its content, so nothing is lost — and the prefix keeps them from colliding with a child element of the same name.
Why did my single-element list not become an array?
Because XML cannot distinguish "a list with one item" from "a single item" — both look identical. Converters have to guess, and this one produces an object for a lone element. If you need a guaranteed array, handle it in your consuming code.
Does it handle namespaces?
Namespace-prefixed element names are kept verbatim, so `soap:Envelope` becomes a key of that exact name. The prefix is preserved rather than resolved to a URI.
Is my XML uploaded?
No. Parsing uses the browser’s own XML parser inside the page. Nothing is transmitted, which matters when the document contains internal data.