UtilityKit

500+ fast, free tools. Most run in your browser only; Image & PDF tools upload files to the backend when you run them.

JSON to XML Converter

Convert JSON objects, arrays, and primitive values into XML with configurable root tags and formatting.

About JSON to XML Converter

Modern applications speak JSON, but legacy enterprise APIs, SOAP services, EDI partners, and XML feed consumers still demand XML payloads. Wrapping a JSON object in tags by hand — escaping ampersands, deciding which keys become attributes, picking a root element name for arrays — takes longer than it should. This converter maps JSON to XML automatically: keys starting with @ become XML attributes, arrays become repeated tags, and null or empty objects become self-closing tags. The generated XML is valid XML 1.0 with automatic entity escaping, and an optional prolog with encoding declaration is added on request. Developers sending requests to legacy SOAP APIs, integrators producing Atom or RSS feeds from JSON sources, and ETL teams targeting XML-only partners all use this. No data leaves the browser tab during conversion.

Why use JSON to XML Converter

Attribute Convention Recognised

Keys starting with @ (or your chosen prefix) become XML attributes on the parent element; all other keys become child elements. This convention is symmetric with the XML-to-JSON tool, making round-tripping between formats predictable.

Configurable Root Element

JSON arrays at the top level need a wrapping root element for valid XML. Set the root element name to match your partner spec (items, records, response, root) instead of getting an arbitrary default that breaks WSDL validation.

XML 1.0 Spec Output

Generated XML is spec-valid XML 1.0: &, <, >, and " inside text nodes and attribute values are entity-escaped automatically. The optional prolog includes encoding="UTF-8" as most SOAP clients and XML validators require.

Pretty-Print or Minified

Switch between indented output for review and debugging in Postman or Insomnia, and single-line minified output for production SOAP payloads and bulk loaders where extra whitespace adds unnecessary bytes to every request.

Self-Closing for Empty Elements

JSON null values and empty objects produce self-closing XML tags like element-slash rather than open-and-close pairs, producing smaller and cleaner output that many XML validators, SOAP processors, and schema validators prefer.

Local Conversion Only

Confidential JSON payloads being converted for a SOAP or EDI partner endpoint stay in your browser tab throughout the process. No data is uploaded, logged, or forwarded to any remote server or third party.

How to use JSON to XML Converter

  1. Paste a JSON object or array into the input panel
  2. Set the attribute prefix (default @) that marks keys which should become XML attributes
  3. Set a root element name for the output — required when the top-level JSON is an array
  4. Toggle the XML prolog (<?xml version="1.0" encoding="UTF-8"?>) on or off based on your target's requirements
  5. Choose between pretty-printed (indented) and minified (single-line) output
  6. Click Convert, verify that entity escaping looks correct, then copy or download as .xml

When to use JSON to XML Converter

  • Building a SOAP request body from a JSON configuration object to send to a legacy enterprise API
  • Generating an Atom or RSS XML feed from JSON data in a static site generator or content pipeline
  • Converting a JSON API response into an XML payload required by an EDI partner or third-party integration
  • Creating an XML sitemap from a JSON array of URL records for submission to search engines
  • Inspecting how a JSON structure maps to XML before writing a serialisation class in Java or C#
  • Debugging an XML integration by converting test JSON fixtures to XML and comparing against expected SOAP payloads

Examples

JSON → SOAP-style XML

Input: { "GetUserRequest": { "@xmlns": "http://api.example.com/", "UserId": 42, "IncludeOrders": true } }

Output: <?xml version="1.0" encoding="UTF-8"?> <GetUserRequest xmlns="http://api.example.com/"> <UserId>42</UserId> <IncludeOrders>true</IncludeOrders> </GetUserRequest>

Array becomes repeated tags

Input: { "library": { "book": [ { "@id": "1", "title": "Effective JS" }, { "@id": "2", "title": "DDIA" } ] } }

Output: <library> <book id="1"> <title>Effective JS</title> </book> <book id="2"> <title>DDIA</title> </book> </library>

Special characters escaped

Input: { "message": "5 < 6 & 6 > 5" }

Output: <message>5 < 6 & 6 > 5</message>

Tips

  • Always set a meaningful root element name when your JSON top level is an array — items or the singular form of the content type reads best for your partner's parser.
  • For SOAP targets, include the prolog with encoding="UTF-8" — many .NET and Java XML clients reject documents without an explicit encoding declaration.
  • Use @-prefixed keys for attributes required by the partner spec; all other keys will become child elements automatically.
  • Round-tripping is reliable for data values but loses comments, processing instructions, and entity declarations — do not put metadata in those.
  • Pretty-print the output for debugging in Postman or Insomnia, then switch to minified for production payloads to reduce request body size.

Frequently Asked Questions

How do I make a JSON key become an XML attribute?
Prefix the key with @ (or your chosen attribute prefix). For example, {"element": {"@id": "42", "title": "Hello"}} produces <element id="42"><title>Hello</title></element>. Keys without the prefix become child elements.
What happens to a top-level JSON array — does XML need a root?
Yes. XML requires exactly one root element, so a top-level JSON array needs a wrapping root element. Set the root element name in the converter (e.g. items or records) before converting. Each array element becomes a child element with a configurable tag name.
Will special characters like & and < be escaped automatically?
Yes. Ampersands become &, less-than signs become <, greater-than signs become >, and double quotes in attribute values become ". This escaping is applied automatically to all text content and attribute values.
Can I include the <?xml version="1.0"?> prolog?
Yes. Toggle the prolog option to include <?xml version="1.0" encoding="UTF-8"?> at the top of the output. Many SOAP clients and .NET XML parsers reject XML without it, so enable it when targeting those systems.
How are JSON nulls and empty objects rendered?
JSON null values and empty objects ({}) produce self-closing XML tags: <fieldName/>. This is semantically equivalent to <fieldName></fieldName> in XML 1.0 and is the more compact form used by most XML serialisers.
Does it support namespaces like xmlns:soap?
Yes. Include the xmlns attribute in your JSON using the @ prefix: {"soap:Envelope": {"@xmlns:soap": "http://...", ...}}. The converter preserves namespace declarations as XML attributes on the element.
Will the output round-trip back to identical JSON?
For data-centric structures without comments or processing instructions, the XML-to-JSON tool will reconstruct the original JSON shape. Attribute prefix conventions must match between the two tools. Exact whitespace and formatting are not preserved.
Are my secrets uploaded?
No. Conversion runs entirely in your browser using JavaScript DOM operations. No data is sent to any server. JSON payloads containing API keys, credentials, or partner data are safe to convert locally.

Explore the category

Glossary

Root element
The single top-level element that wraps all other elements in a valid XML document. XML requires exactly one root element, so JSON arrays must be wrapped in a named root when converting to XML.
Attribute prefix
A character prepended to JSON keys to indicate that the corresponding value should become an XML attribute rather than a child element. The @ character is the convention used by xml-js; $ is used by xml2js.
XML prolog
The optional declaration at the start of an XML document: <?xml version="1.0" encoding="UTF-8"?>. Many XML parsers, SOAP clients, and validators expect or require this declaration to appear before any elements.
Self-closing tag
An XML element written as <tagName/> rather than <tagName></tagName>, used for elements with no text content or child elements. Self-closing tags are produced for JSON null values and empty objects.
Entity escaping
The process of replacing special XML characters in text content and attribute values with their named entity references: & → &, < → <, > → >, " → ". Required for valid XML 1.0 output.
Element repetition
The XML pattern where multiple sibling elements share the same tag name to represent an array. A JSON array [{"item": 1}, {"item": 2}] produces two repeated <item> elements as siblings under a parent element.