JSON to XML

Converts JSON to well-formed XML. Special characters are escaped automatically.

Input JSON
1
XML Output

Paste JSON on the left to convert to XML

Example: {"name": "Ravi", "city": "Surat"}

2sp · UTF-8

Example Conversion

JSON:

json
{
  "user": {
    "name": "Ravi Mehta",
    "age": 28,
    "roles": ["admin", "editor"]
  }
}

XML (root tag: root):

xml
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <user>
    <name>Ravi Mehta</name>
    <age>28</age>
    <roles>
      <item>admin</item>
      <item>editor</item>
    </roles>
  </user>
</root>

JSON vs XML — Key Differences

FeatureJSONXML
ReadabilityGoodVerbose
File sizeSmallerLarger
CommentsNoYes
AttributesNoYes
NamespacesNoYes
SchemaJSON SchemaXSD, DTD
Best forREST APIsSOAP, RSS, Office

Special Character Escaping

XML has five reserved characters that must be escaped inside element content. JSONKit handles all escaping automatically:

CharacterEscaped as
&&amp;
<&lt;
>&gt;
"&quot;
'&apos;

When to Use XML

  • SOAP web servicesEnterprise APIs that use SOAP protocol require XML payloads
  • RSS and Atom feedsAll RSS and Atom feed formats are XML-based
  • Microsoft OfficeDOCX, XLSX and PPTX files are zipped XML documents internally
  • Legacy enterpriseMany banking and government systems only accept XML
  • SVG graphicsSVG vector graphics are XML — convert JSON shape data to SVG

Frequently Asked Questions

Every XML document must have exactly one root element. JSONKit wraps all content in a configurable root tag (default: 'root'). Change it in the input field in the page header.

Array items become repeated <item> elements inside the parent element. For example a JSON array [1,2,3] becomes <parent><item>1</item><item>2</item><item>3</item></parent>.

Not on this page. XML to JSON conversion is a planned feature. For now, use an external XML parser.

XML element names must start with a letter and can only contain letters, digits, hyphens, underscores and periods. Invalid characters are automatically replaced with underscores.

Related Tools