Skip to content
Browser tool Runs locally

JSON to XML Converter

Convert JSON to valid XML with predictable rules for objects, arrays, attributes, text, and root elements.

JSON input
0 chars
XML output
Converted XML will appear here.
Examples:

How to convert JSON to XML

  1. Paste JSON.
  2. Confirm the Root element.
  3. Click Convert to XML.

How JSON objects become XML elements

Each property becomes a child element; primitives become text.

How JSON arrays become XML elements

An array value produces repeated sibling elements using the singularized name.

How XML attributes are represented in JSON

Properties beginning with @ become attributes.

Common reasons to convert JSON to XML

  • Building a request body for a SOAP or legacy XML-based API
  • Generating a config file for a system that expects XML input
  • Producing an RSS/Atom feed or sitemap from structured data

XML naming and structure constraints

XML is stricter about names than JSON: element names can't contain spaces or most punctuation, can't start with a digit, and every document needs exactly one root element. Deeply nested objects and arrays convert fine, but very large or unusually shaped JSON (arrays of arrays, for example) may need a wrapping element added so the array items have somewhere to nest.

Data that may need adjusting first

Keys with spaces, leading digits, or reserved prefixes should be renamed before converting. Values you want as XML attributes should use the @ prefix ahead of time, and any text that needs to sit alongside attributes or children should be moved into a #text property so it isn't lost.

Frequently asked questions

Does the JSON get uploaded?
No. Conversion runs entirely in your browser.
Why do I need to set a root element?
Unlike JSON, which can have an array or object at the top level, a well-formed XML document must have exactly one root element wrapping everything else, so the converter needs a name to use for it.
What should I do about keys that aren't valid XML names?
XML element names can't contain spaces, can't start with a digit or punctuation, and can't start with the letters xml. Rename keys like "first name" or "2nd-place" before converting, or the output may not be well-formed.
What happens to null or mixed-type array values?
A null value typically becomes an empty element, and arrays that mix objects, strings, and numbers still produce one sibling element per item; inconsistent types across an array are worth normalizing first if the resulting XML needs to follow a strict schema.
Will converting to XML and back give me the original JSON?
Not always. XML attribute values are always strings, so numbers and booleans stored as attributes come back as strings after a round trip, and any properties that don't map cleanly to attributes, text, or elements may need cleanup.

Related tools