Convert JSON to XML with an explicit type mapping
Use this JSON to XML converter when a service or workflow needs XML instead of JSON. Because JSON and XML organize data differently, the converter uses a documented mapping: objects become nested property elements, array entries become ordered item elements, and every element carries a type attribute.
Paste valid JSON or open a local .json file. Choose a root element name, indentation, and whether to include an XML declaration. The converter checks the generated document with the browser's XML parser before enabling Copy and Download.
Example: JSON object converted to XML
With the default root name, this JSON:
{
"name": "Catalog",
"enabled": true,
"retries": 3
}
becomes typed XML:
<?xml version="1.0" encoding="UTF-8"?>
<root type="object">
<property name="name" type="string">Catalog</property>
<property name="enabled" type="boolean">true</property>
<property name="retries" type="number">3</property>
</root>
The type attributes keep values such as the string "3" distinct from the number 3. JSON keys are stored in the name attribute, so keys do not have to be valid XML element names.
How to convert JSON to XML
- Paste JSON into the input area, choose Open JSON, or drop a JSON file into the input panel. The file limit is 50 MiB.
- Set a root element name. It must start with a letter or underscore; later characters may include letters, numbers, dots, hyphens, or underscores. Names beginning with
xmlare reserved. - Choose two- or four-space indentation, and select whether to pretty print and include the XML declaration.
- Select Convert to XML. Check the status and the displayed root type and output size.
- Copy the XML or download it as
converted.xml.
How JSON values are represented
- Objects: Each key-value pair becomes a
propertyelement with the original key in itsnameattribute. - Arrays: Each value becomes an
itemelement. The order of array items is preserved. - Strings, numbers, and booleans: Values are written as escaped text with a type attribute.
- Null and empty collections: Null, an empty object, and an empty array remain distinct through their type attributes, even when represented by self-closing elements.
- Root values: The selected root element wraps the document's top-level value, whether it is an object, array, or scalar.
Text and attribute values are escaped for XML. Characters that XML 1.0 does not allow cause conversion to stop with an error instead of producing an invalid document.
This mapping is not an application-specific XML schema
The output is well-formed typed XML, but it is not automatically a SOAP message, RSS feed, configuration vocabulary, or XML document for a particular API. Some systems require exact element names, attributes, namespaces, ordering, or an XML Schema. Adapt the output to that contract and validate it with the receiving application before using it.
The converter checks that a browser can parse the generated XML. Well-formedness means the tags and document structure are valid XML; it does not mean the content matches a system's schema or business rules.
Numbers and browser compatibility
Some browsers expose the original text of JSON numbers to the converter, allowing the XML output to retain their numeric spelling. If a browser cannot preserve an integer outside JavaScript's safe range, the converter rejects it rather than silently writing a rounded value. Decimal precision on those browsers follows JavaScript number behavior. For identifiers, consider storing digits as a JSON string when the consuming system expects text.
Where is the JSON processed?
The converter reads the pasted text or selected file in your browser and uses the browser's built-in XML parser to check the output. The conversion script does not send the JSON to a server. Avoid entering credentials or confidential records into any website unless you trust its data handling.
JSON to XML and related tools
Use the JSON Validator to check JSON syntax before conversion, or the JSON Editor to change the source data. The JSON to YAML Converter is useful when the receiving system expects YAML. Choose the target format required by the application that will read the data.
Frequently asked questions
Can I convert nested JSON objects and arrays?
Yes. Nested objects become nested property elements, and arrays become ordered item elements.
Why does the output include a root element?
XML needs one document element. The converter wraps the top-level JSON value in the root name you choose, which defaults to root.
Can I use the result with any XML application?
Not necessarily. The result uses this converter's typed mapping. Check the receiving application's required element names, namespaces, schema, and version.
Does the converter check my XML schema?
No. It parses the generated document to check that it is well-formed XML. Schema validation must be done against the rules for the target system.
Can JSON be converted back from this XML?
A converter that understands these type, property, and item conventions can reconstruct the corresponding JSON structure. Arbitrary XML does not have one universally correct JSON representation.
Does the converter preserve large numbers?
It preserves numeric text when the browser exposes the original JSON number token. In browsers without that support, unsafe integers are rejected to avoid silent rounding. Review precision-sensitive decimals as well.
Can I change the root element and formatting?
Yes. Enter a valid root name, select two or four spaces, and toggle pretty printing or the XML declaration. Changing an option clears the old output until you convert again.
Is my JSON uploaded?
The conversion script processes your JSON in the browser and does not send the document to a server. Do not paste sensitive data into a website unless you are comfortable with its data handling.