Runs in your browser. Your files and text never leave your device - nothing is uploaded.
Convert JSON to XML Online
The Tools Kit’s free JSON to XML converter turns a JSON object into indented XML in your browser. Paste JSON from an API response, a config file, or test data, click Convert to XML, and copy the result. Each key becomes an element, nested objects become nested elements, and arrays become repeated elements, all inside an XML declaration and a single<root> element.
Nothing is uploaded: the JSON is parsed and the XML is assembled by JavaScript on your own device. If your JSON is messy or minified, tidy it first with the JSON formatter so parse errors are easier to spot.
How to Convert JSON to XML
- 1
Paste your JSON
Paste a JSON object into the JSON Input box, or edit the sample that is already filled in. The top level should be an object wrapped in curly braces.
- 2
Click Convert to XML
The JSON is parsed in your browser. If it is not valid, an "Invalid JSON" message explains what the parser could not read.
- 3
Review the XML output
The right-hand panel shows the XML with an XML declaration, a root element, and two-space indentation for each nesting level.
- 4
Copy the result
Click Copy XML to put the converted markup on your clipboard, ready to paste into a file, request body, or config.
There is no account to create and no limit on how many conversions you run.
How JSON Maps to XML: A Worked Example
JSON and XML describe data differently. JSON has objects, arrays, strings, numbers, booleans and null; XML has only elements, attributes and text. This converter uses the most common element-only mapping. Here is a small order record:
{
"order": {
"id": 7,
"items": [
{ "sku": "A1", "qty": 2 },
{ "sku": "B2", "qty": 1 }
],
"note": "Fish & chips",
"paid": true,
"coupon": null
}
}Clicking Convert to XML produces exactly this output:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<order>
<id>7</id>
<items>
<sku>A1</sku>
<qty>2</qty>
</items>
<items>
<sku>B2</sku>
<qty>1</qty>
</items>
<note>Fish & chips</note>
<paid>true</paid>
<coupon>null</coupon>
</order>
</root>- Objects —
orderbecomes an<order>element containing one child per key. - Arrays — the two entries in
itemsbecome two sibling<items>elements; there is no extra wrapper. - Numbers and booleans — written as plain text (
7,true), since XML text carries no data type. - null — written as the text
null, not as an empty or omitted element. - Reserved characters — the ampersand in “Fish & chips” is escaped to
&.
Getting Valid XML From Your JSON
Because JSON allows almost any string as a key but XML names are strict, a few inputs need preparing before conversion. Key names are copied straight into tag names, so:
- Start with an object. A top-level array gives tags named
<0>,<1>and so on, which are not legal XML. Wrap it, for example{"item": [ ... ]}. - Avoid spaces and leading digits in keys.
"first name"or"2024"make invalid tags; rename them to something likefirst_nameory2024. - Expect arrays of arrays to flatten. Inner arrays are not nested; their items join the same run of repeated sibling elements.
- Empty arrays disappear. A key holding
[]produces no element in the output.
After converting, paste the result into the XML formatter to validate and re-indent it. If you only need to escape a snippet of text for HTML or XML rather than convert a whole document, the HTML entity encoder handles that.
JSON vs XML: When You Still Need XML
JSON is the default for modern web APIs, but XML remains common in SOAP web services, RSS and Atom feeds, sitemaps, Android resources, Maven and .NET project files, and many enterprise, banking and government data exchanges. Converting JSON to XML is usually about feeding data from a JSON-speaking system into one of these XML-only consumers.
Going the other way, the XML to JSON converter turns XML back into JSON. For spreadsheet-friendly output, try JSON to CSV, and if your source data is in YAML, convert it with YAML to JSON first and then run it through this tool. All of these live in the conversion tools collection.
Common uses
- Turning a JSON API response into an XML request body for a SOAP or legacy service
- Generating XML test fixtures or sample payloads from existing JSON data
- Migrating configuration values from a JSON file to an XML config format
- Seeing how a JSON structure would look as XML before writing a conversion script
- Teaching or learning the differences between the two data formats side by side
JSON to XML terms explained
| Term | What it means here |
|---|---|
| Element | A named pair of tags such as <name>Alice</name>; every JSON key becomes one |
| Root element | The single outer element an XML document must have; this tool always uses <root> |
| XML declaration | The first line, <?xml version="1.0" encoding="UTF-8"?>, stating the XML version and character encoding |
| Attribute | A name="value" pair inside an opening tag; JSON has no equivalent, so this converter never creates attributes |
| Entity | An escaped stand-in for a reserved character, such as & for & or < for < |
| Well-formed XML | XML that follows the syntax rules: one root, properly nested and closed tags, legal tag names, escaped text |
Frequently Asked Questions
Paste a JSON object into the JSON Input box and click Convert to XML. The XML appears in the output panel with an XML declaration and a <root> element, and you can copy it with the Copy XML button. It is free and needs no signup.
Each item in an array becomes its own element, repeated with the array key as the tag name. "tags": ["admin", "user"] becomes <tags>admin</tags> followed by <tags>user</tags>. There is no wrapper element around the group and no generic <item> tag.
A nested object becomes a nested element: its key is the parent tag and each of its own keys becomes a child element, indented two more spaces. This works at any depth of nested objects.
Numbers and booleans are written as text, so 30 becomes <age>30</age> and true becomes <paid>true</paid>. A null value becomes the text null, for example <coupon>null</coupon>. An empty array produces no element at all.
An XML document must have exactly one top-level element, while a JSON object can have many top-level keys. The converter always wraps your keys inside <root> so the result has a single root. The root name is fixed and cannot be changed in the tool.
No. Every JSON key becomes a child element, never an attribute. If a target schema expects attributes, you will need to edit those parts of the output by hand.
Yes. In values, the five reserved characters are replaced with entities: & becomes &, < becomes <, > becomes >, a double quote becomes " and an apostrophe becomes '.
Not cleanly. The converter expects a JSON object at the top level. A top-level array produces tags named after the index numbers, such as <0> and <1>, which are not valid XML names. Wrap the array in an object first, for example {"item": [ ... ]}, to get repeated <item> elements.
Key names are used as tag names exactly as written. XML names cannot contain spaces or start with a digit, so keys like "first name" or "1a" give tags that XML parsers will reject. Rename such keys, for example to first_name, before converting.
No. The JSON is parsed and the XML is built by JavaScript running in your browser, so the data you paste is not sent to The Tools Kit or anyone else.
Yes, with the separate XML to JSON converter on this site. Note that a round trip may not return identical JSON: XML text has no data types, so numbers, booleans and null come back as text rather than typed JSON values, and the structure may differ from your original.
Reviewed by Raja Jahangir · Last reviewed: October 7, 2026
How do you convert JSON to XML?
To convert JSON to XML, paste a JSON object and click Convert to XML. Each key becomes an element, nested objects become nested elements, arrays repeat the element once per item, and the output is wrapped in a <root> element with an XML 1.0 UTF-8 declaration. Special characters such as < and & are escaped automatically.
