JSON ↔ XML Converter
Convert between JSON and XML — round-trippable for nested objects, arrays and primitives.
Quick answer: JSON ↔ XML Converter: convert between JSON and XML — round-trippable for nested objects, arrays and primitives. Runs entirely in your browser, free, no signup.
Last updated
Good to know
JSON and XML model data differently, so the conversion is a best-effort mapping rather than a perfect round trip. JSON has arrays, objects, and typed primitives; XML has elements, attributes, ordered children, and mixed content. This tool maps object keys to element names and repeated elements to arrays, which covers the common case of hierarchical, element-only documents cleanly.
The biggest limitation to plan around is attributes. Attribute-heavy formats like SVG, XAML, or many configuration schemas store meaning in <tag attr="x">, and that information is not modeled here — so those conversions are lossy. Likewise, an element that happens to appear only once becomes a JSON object rather than a single-element array, which can surprise code that always expects a list. If your XML contract requires an array, wrap repeated elements in a parent container.
Because XML type information is weak (everything is text unless a schema says otherwise), a number like 42 may come back as the string "42" after a round trip. Coerce types explicitly in your consuming code rather than assuming they survived.
If your goal is simply to tidy up an XML document rather than convert it, the XML formatter preserves attributes, namespaces, and CDATA that this converter drops. For JSON-to-config workflows, the JSON ↔ YAML converter is often a better fit than XML.
Frequently asked questions
- Why are arrays sometimes mis-detected on XML → JSON?
- An XML element appearing exactly once becomes an object, not a single-item array. If you need an array always, post-process the result or wrap repeated elements in a parent container.
- What about XML attributes?
- We don't currently model attributes — only element content and child elements. For attribute-heavy XML (SVG, XAML) the conversion is lossy.
- Will mixed content (text + elements) survive?
- Partially — text is preserved but the order of mixed text/elements may change. JSON has no native mixed-content model.
- Are namespaces preserved?
- Element names retain their namespace prefix (e.g. <code>soap:Envelope</code>) but namespace declarations are lost on the JSON side.
- Are my files uploaded?
- No — both directions run entirely in your browser.