Data

JSON to XML Converter

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

Loading interactive tool…

Embed this tool on your site

About this tool

Modern applications speak JSON, but legacy enterprise APIs, SOAP services and XML feed consumers still demand XML payloads. Wrapping a JSON object in tags by hand — escaping ampersands and nesting every level correctly — takes longer than it should. This converter maps JSON to XML as you type: each object key becomes a child element, each array item becomes an <item> element inside its parent, and strings, numbers and booleans become text content with &, <, >, " and ' escaped. The whole document is wrapped in a root element you name (root by default) and always starts with an <?xml version="1.0" encoding="UTF-8"?> prolog. Output is indented with 2 spaces, or written on one line when you untick Pretty indent. There is no attribute mapping: every key becomes an element, so keys must already be valid XML names — a key such as @id or one with spaces produces markup that XML parsers reject. No data leaves the browser tab during conversion.

Why use it

  • Live Conversion: The XML output updates on every keystroke and whenever you change the root tag or indent setting, so fixing a JSON typo shows the result immediately.

  • Configurable Root Element: Every document is wrapped in a root element you name — items, records, response — so a top-level array or several top-level keys still produce a single-rooted XML document.

  • Automatic Escaping: &, <, >, " and ' inside values are written as &amp;, &lt;, &gt;, &quot; and &apos;, so text such as 5 < 6 & 6 > 5 stays valid XML.

  • Pretty-Print or Single Line: Keep the 2-space indented layout for review in Postman or Insomnia, or untick Pretty indent to get the whole document on one line for compact payloads.

  • Root Tag Validation: The root tag must start with a letter or underscore and contain only letters, numbers, dot, dash and underscore; anything else shows an error instead of broken output.

  • 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

  1. Paste a JSON object or array into the JSON input box
  2. Set the Root tag name that will wrap the whole document (root by default)
  3. Leave Pretty indent (2 spaces) checked for readable output, or untick it for a single line
  4. Read the XML output, which updates as you type
  5. Use Beautify to re-indent your JSON input, then Copy the XML

When it helps

  • Building a simple XML request body from a JSON object for a legacy enterprise API
  • Converting a JSON API response into an XML payload required by a third-party integration
  • Inspecting how a JSON structure maps to nested XML elements before writing a serialisation class in Java or C#
  • Producing test XML fixtures from JSON data
  • Debugging an XML integration by converting test JSON fixtures to XML and comparing against expected payloads

Examples

Nested object with an array

Input
{"user":{"id":42,"roles":["admin","editor"]}}
Expected result · Scroll for more
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <user>
    <id>42</id>
    <roles>
      <item>admin</item>
      <item>editor</item>
    </roles>
  </user>
</root>

Top-level array, root tag items, Pretty indent off

Input
[{"sku":"A-1"},{"sku":"B-2"}]
Expected result
<?xml version="1.0" encoding="UTF-8"?><items><item><sku>A-1</sku></item><item><sku>B-2</sku></item></items>

Special characters escaped

Input
{ "message": "5 < 6 & 6 > 5" }
Expected result
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <message>5 &lt; 6 &amp; 6 &gt; 5</message>
</root>

Tips

  • Set a meaningful root tag — items or the plural of your content type reads best for the receiving parser.
  • Rename keys that start with @ or contain spaces before converting; XML element names cannot contain them.
  • If your partner expects repeated sibling tags instead of <item> wrappers, rename the <item> elements in the output by hand.
  • Delete the prolog line from the output if the receiving system rejects an XML declaration.
  • Keep Pretty indent on while debugging in Postman or Insomnia, then untick it for a one-line payload.

Frequently Asked Questions

Can a JSON key become an XML attribute?
No. Every key becomes a child element, including keys that start with @. Because @ is not allowed in XML element names, a key like @id produces <@id>…</@id>, which XML parsers reject. Rename such keys before converting and add attributes by hand.
What does the root tag do?
XML needs exactly one root element, so the converter always wraps the output in the Root tag you enter (root by default), whether the JSON is an object, an array or a single value. The name must start with a letter or underscore.
How are JSON arrays converted?
Each array item becomes an <item> element inside the element for the array's key. For example, {"roles": ["admin", "editor"]} becomes <roles><item>admin</item><item>editor</item></roles>.
Will special characters like & and < be escaped automatically?
Yes. In text content, & becomes &amp;, < becomes &lt;, > becomes &gt;, a double quote becomes &quot; and an apostrophe becomes &apos;.
Is the <?xml version="1.0"?> prolog included?
Always. Every output starts with <?xml version="1.0" encoding="UTF-8"?>; there is no option to leave it out, so delete the line by hand if your target rejects it.
How are JSON nulls and empty objects rendered?
null, an empty object and an empty array all produce an empty open-and-close pair such as <fieldName></fieldName>. Self-closing tags are not used.
Are my secrets uploaded?
No. Conversion runs entirely in your browser using JavaScript string building. 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, which is why this converter always wraps its output in the root tag you choose.
XML element name
The tag name of an element. It must start with a letter or underscore and cannot contain spaces or characters such as @, so JSON keys like @id or first name cannot be used as element names unchanged.
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>. The two forms are equivalent in XML; this converter always writes the open-and-close form.
Entity escaping
Replacing special characters in XML text with entity references: & becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot; and ' becomes &apos;. Required for valid XML 1.0 output.
Element repetition
The XML pattern where multiple sibling elements share the same tag name to represent a list. This converter represents JSON arrays as repeated <item> elements inside the parent element.
A LITTLE HELP. A LOT DONE.
Good tools.
Great flow.

Your shortcut to the everyday. Create, convert, calculate,
and get back to what you love.

✓ Free to use✓ No sign-up✓ 500+ possibilities