Overview
What this converter does
Convert JSON to XML and XML back to JSON, in both directions, with validation and clear error messages. Repeated XML elements become JSON arrays. It runs entirely in your browser using the built-in JSON and XML parsers, so your data is never uploaded.
Two data formats
JSON vs XML
Both store structured data, but they have different strengths:
| JSON | XML | |
|---|---|---|
| Readability | Compact, easy to scan | Verbose |
| Data types | Strings, numbers, booleans, null, arrays | Everything is text |
| Native to | JavaScript / web APIs | Enterprise, documents, config |
| Comments | Not supported | Supported |
| Attributes | No (keys only) | Yes |
| Best for | Web APIs, configs | Documents, legacy systems, SOAP |
Most modern web APIs use JSON because it's lighter and maps directly to JavaScript objects. XML remains common in enterprise software, document formats (like DOCX and SVG), RSS feeds, and older SOAP web services.
The rules
How the conversion works
JSON to XML
Each key becomes a tag and its value becomes the tag's content. Nested objects become nested elements. An array becomes repeated elements with the same tag name. The whole thing is wrapped in a single root element, since XML requires exactly one.
XML to JSON
Each element becomes a key. When several sibling elements share a tag name, they're collected into a JSON array. An element with only text becomes a string value; an element with children becomes a nested object.
See it in action
A worked example
This JSON:
{ "person": { "name": "Ada", "skills": ["math", "code"] } }
becomes this XML:
<root><person><name>Ada</name><skills>math</skills><skills>code</skills></person></root>
Notice the array skills became two repeated <skills> elements — and converting back turns them into an array again.
Behind the scenes
Privacy and how it runs
Runs in your browser
Common questions
How do I convert JSON to XML?
Paste valid JSON in JSON-to-XML mode. The tool builds an equivalent XML document instantly, which you can copy with one click. Invalid JSON is flagged with the parse error.
How are arrays handled?
A JSON array becomes repeated XML elements with the same tag name. Going the other way, repeated sibling elements become a JSON array. This is the standard convention for representing lists across the two formats.
Why does XML need a single root element?
The XML specification requires exactly one top-level (root) element that contains everything else. That's why the converter wraps JSON data in a root element. If your XML has multiple top-level elements, it's invalid and won't parse.
Does it handle XML attributes?
The converter focuses on element structure and text content, which covers most data-exchange needs. Attributes (values inside the opening tag) are a more specialized XML feature; heavily attribute-based XML may need a dedicated parser.
Why am I getting an "invalid XML" error?
Usually an unclosed or mismatched tag, or more than one root element. Check that every <tag> has a matching </tag> and that there's a single wrapping element.