Output will appear here
Output will appear here
Paste JSON and get well-formed XML with an <?xml ?> declaration and a <root> element. Each key becomes a child element. Arrays become a wrapper element named after the key with one child per item, using the singular form of the key (tags gives <tag>). &, <, > and quotes in text are escaped.
By Ankit Aglawe · Updated · Runs entirely in your browser
lines becomes <lines> with two <line> children. The & in the customer name is written as &. Numbers and booleans become element text, and 19.0 is printed as 19.
{
"invoice": {
"number": "INV-2041",
"issued": "2024-03-01",
"customer": { "name": "Fischer & Sons", "vatId": "DE123456789" },
"lines": [
{ "sku": "HOST-M", "qty": 12, "unitPrice": 19.0 },
{ "sku": "SUPPORT", "qty": 1, "unitPrice": 250 }
],
"paid": false
}
}<?xml version="1.0" encoding="UTF-8"?>
<root>
<invoice>
<number>INV-2041</number>
<issued>2024-03-01</issued>
<customer>
<name>Fischer & Sons</name>
<vatId>DE123456789</vatId>
</customer>
<lines>
<line>
<sku>HOST-M</sku>
<qty>12</qty>
<unitPrice>19</unitPrice>
</line>
<line>
<sku>SUPPORT</sku>
<qty>1</qty>
<unitPrice>250</unitPrice>
</line>
</lines>
<paid>false</paid>
</invoice>
</root>The space in user name becomes _, and 2fa gets a _ prefix because XML names cannot start with a digit. Hyphens are allowed and kept. data has no plural s, so its children are called <item>. null and the empty array both become self-closing tags.
{
"user name": "kim",
"2fa": true,
"x-request-id": "a1b2",
"roles": ["admin"],
"data": [3, 5],
"manager": null,
"groups": []
}<?xml version="1.0" encoding="UTF-8"?>
<root>
<user_name>kim</user_name>
<_2fa>true</_2fa>
<x-request-id>a1b2</x-request-id>
<roles>
<role>admin</role>
</roles>
<data>
<item>3</item>
<item>5</item>
</data>
<manager />
<groups />
</root>Letters in any script, digits, _, . and - are kept, so café and 名前 stay as they are. Anything else becomes _, and a name starting with anything other than a letter or _ gets a _ prefix. So user name gives <user_name> and 1st gives <_1st>. Two keys can end up with the same tag name, such as a b and a_b.
An array is written as a wrapper plus one child per item. The child name is a simple singular: categories gives category, classes, boxes, matches and statuses drop es, houses and users drop the s, and anything else, like data or status, becomes item. A nested array produces nested <item> elements.
A one-element array still gets its wrapper, so "roles": ["admin"] becomes <roles><role>admin</role></roles>. A consumer reading that XML back cannot tell it from a single object without a schema.
Every key becomes a child element. Keys such as @id or #text are not treated as attributes or text nodes; they are sanitized to <_id> and <_text>.
All three become a self-closing tag like <manager />. XML has no null, so if the difference matters, add an explicit flag in your JSON.
XML text has no types, so 42, true and "42" all look the same in the output. In text, &, <, >, " and ' are escaped as entities. There is no CDATA output.
XML 1.0 forbids most control characters, such as \u0001 or \u0000, even as  references. They are replaced with U+FFFD (�) so the output always parses. Tabs and line breaks are kept.
The outer element is always <root>. A top-level array puts each item directly under it as <item>.
| JSON | XML | Notes |
|---|---|---|
{"name": "kim"} | <name>kim</name> | Inside <root> |
"tags": ["a", "b"] | <tags><tag>a</tag>...</tags> | Singular child name |
"data": [1, 2] | <data><item>1</item>...</data> | item when no plural |
null, [], {} | <key /> | All self-closing |
"a & b" | a & b | Entity-escaped |
"user name" key | <user_name> | Invalid chars become _ |
"2fa" key | <_2fa> | Cannot start with a digit |
Enter a JSON object or array in the left editor. The converter supports nested structures, arrays, and all JSON value types.
The right pane shows well-formed XML with proper element nesting, indentation, and an XML declaration header.
Copy the XML or download it as an .xml file for use in SOAP services, legacy system integrations, or XML-based data pipelines.
Paste the JSON in the left pane. The XML appears on the right with a UTF-8 declaration and a root element. Download it as a .xml file.
It is always root. Wrap your JSON in an object with one key, like {"invoice": {...}}, to get a meaningful element under it.
No. Every JSON key becomes a child element. If you need attributes, edit the output or use an XSLT step after conversion.
As a wrapper element named after the key, with one child per item. The child name is the singular of the key, or item when it cannot be guessed.
Yes. Names are sanitized, text is escaped, and control characters that XML 1.0 forbids, such as \u0001, are replaced with U+FFFD.
No. The XML is generated in your browser.
Need several formats at once? Convert All shows every output from one paste. Or browse all JSON converters.