Free JSON to XML Converter - Instant Online Tool

Convert JSON data to well-formatted XML

Convert JSON to XML

This tool is a free JSON to XML converter that transforms JSON data into well-formatted XML. Paste or type JSON on the left, and valid XML appears on the right. Customize the root element name, array item tag, indentation, and XML declaration.

Conversion Examples

JSON Input

{
  "user": {
    "name": "Alice",
    "age": 25,
    "active": true
  }
}

XML Output

<root>
  <user>
    <name>Alice</name>
    <age>25</age>
    <active>true</active>
  </user>
</root>

JSON Array

{
  "colors": ["red", "green", "blue"]
}

XML Output

<root>
  <colors>
    <item>red</item>
    <item>green</item>
    <item>blue</item>
  </colors>
</root>

Nested Objects and Mixed Types

JSON Input

{
  "order": {
    "id": 1042,
    "items": [
      {"sku": "A1", "qty": 2},
      {"sku": "B3", "qty": 1}
    ],
    "shipped": false,
    "note": null
  }
}

XML Output

<root>
  <order>
    <id>1042</id>
    <items>
      <item>
        <sku>A1</sku>
        <qty>2</qty>
      </item>
      <item>
        <sku>B3</sku>
        <qty>1</qty>
      </item>
    </items>
    <shipped>false</shipped>
    <note/>
  </order>
</root>

Nested objects map to nested elements. Booleans become text ("true"/"false"). Null values become self-closing tags.

About JSON to XML Conversion

JSON (JavaScript Object Notation) and XML (Extensible Markup Language) are both data interchange formats. JSON is compact and dominant in REST APIs, JavaScript applications, and NoSQL databases. XML is verbose but supports attributes, namespaces, schemas (XSD), and mixed content — it remains the standard for SOAP web services, RSS/Atom feeds, SVG graphics, Office documents, and enterprise configuration files.

How the mapping works

  • Objects become parent elements with nested child elements for each key.
  • Arrays become repeated child elements inside a wrapper. The child tag name defaults to "item" but is configurable.
  • Strings, numbers, booleans become text content inside their element.
  • Null values become self-closing elements (e.g., <field/>).
  • Invalid tag names are automatically sanitized — characters that are not valid in XML tag names are replaced with underscores.

When to convert JSON to XML

  • Integrating with SOAP-based APIs that require XML request bodies.
  • Generating configuration files (Maven pom.xml, Android manifests, Spring beans).
  • Transforming API responses for systems that consume XML feeds.
  • Creating test fixtures for XML parsers or XSLT pipelines.
  • Importing data into tools or databases that only accept XML.

Special Characters

Five characters are reserved in XML: & < > " '. This converter automatically escapes them to their XML entity equivalents (&amp;, &lt;, &gt;, &quot;, &apos;) so the output is always valid XML.

Frequently Asked Questions

How do I convert JSON to XML?

Paste your JSON into the input field. The converter parses it and maps objects to XML elements, arrays to repeated child elements, and primitive values to text content. The output appears instantly. You can copy or download the result.

What is the difference between JSON and XML?

JSON uses key-value pairs and arrays with curly braces and brackets. XML uses nested opening and closing tags. JSON is more compact and is the default for REST APIs. XML supports attributes, namespaces, and mixed content, and is common in SOAP services, RSS feeds, and configuration files.

How are JSON arrays converted to XML?

Each array element becomes a repeated child element inside a parent tag. By default the child tag is named "item", but you can change this using the Array Item Name option. For example, {"colors":["red","green"]} becomes <colors><item>red</item><item>green</item></colors>.

What happens to null values during conversion?

JSON null values are converted to self-closing XML elements. For example, {"middleName":null} becomes <middleName/>.

Does the converter handle special characters?

Yes. Characters reserved in XML — ampersand (&), less-than (<), greater-than (>), double quote ("), and apostrophe (') — are automatically escaped to their XML entities.

Can I convert XML back to JSON?

This tool converts JSON to XML only. For the reverse direction, use the XML to JSON Converter on this site.

What is the XML declaration and do I need it?

The XML declaration (<?xml version="1.0" encoding="UTF-8"?>) tells parsers which XML version and character encoding to use. Most parsers handle UTF-8 by default, so it is optional but recommended for interoperability. You can toggle it on or off with the checkbox above.

What are valid XML tag names?

XML tag names must start with a letter or underscore and can contain letters, digits, hyphens, underscores, and periods. This converter automatically sanitizes JSON keys that contain invalid characters by replacing them with underscores.

Is my data sent to a server?

No. This converter runs entirely in your browser using JavaScript. Your JSON data is never uploaded to any server. Nothing is stored or logged.

Privacy and Limitations

Privacy: All conversion runs locally in your browser. No data is transmitted to any server. Your JSON input and XML output remain on your device.

Limitations: This tool converts valid JSON to XML. It does not support JSON with comments, trailing commas, or other non-standard extensions. It does not generate XML attributes from JSON (unless the "Convert simple values to attributes" option is enabled). Very large JSON documents may be slow to convert depending on your browser.

Related Tools

Related Tools

View all tools
Request a New Tool
Improve This Tool