Skip to content
Tools

JSON to XML Converter

Last updated:

Paste JSON and get well-formed XML: each key becomes an element, arrays become repeated elements with the same name, and characters like < and & are escaped. Use it to feed SOAP services, legacy integrations or XML-only import tools.

Runs in your browser: the JSON you convert never leaves your device – nothing is uploaded, logged or stored on a server. How we protect your data

100% in-browserNothing is uploaded

Input

Loading editor…

Paste JSON here

or drop a file anywhere in this box. Everything stays in your browser.

Drop a file to load it

Output

Loading editor…

XML appears here

Results update as you type.

How to use the JSON to XML

  1. Paste the JSON. A single top-level key becomes the root element; otherwise a wrapper root is added.
  2. Review element names: keys that are not valid XML names are adjusted.
  3. Check how arrays came out – each item repeats the parent key's element.
  4. Copy or download the .xml file.

Worked example

A book with two tags

Input

{"book":{"id":"b1","title":"Dune & Sons","tags":["sci-fi","classic"],"price":9.99}}

XML

<?xml version="1.0" encoding="UTF-8"?>
<book>
  <id>b1</id>
  <title>Dune &amp; Sons</title>
  <tags>sci-fi</tags>
  <tags>classic</tags>
  <price>9.99</price>
</book>

The & is escaped as &amp;. The two-item array produces two <tags> elements; a one-item array produces one, which is indistinguishable from a plain value once in XML.

What does not map one-to-one

What does not map one-to-one
JSON featureXML outcome
Several top-level keysWrapped in a single root element (XML allows only one)
Key like "2fa" or "first name"Not a valid element name; adjusted, e.g. prefixed or with _
ArraysRepeated sibling elements
nullEmpty element such as <x/>
Numbers and booleansText; XML has no types without a schema
Nested arrays [[1,2]]Need a wrapper element per inner array

Attributes

JSON has no concept of attributes, so by default everything becomes child elements. Many converters adopt a convention where a key prefixed with @ (for example "@id") is written as an attribute and "#text" as element text. If the target system needs attributes, check the converter options for such a prefix and rename the keys before converting.

Escaping and encoding

Inside element text, < and & must be escaped as &lt; and &amp;; the converter does this for you. Control characters below U+0020 other than tab, newline and carriage return are not allowed in XML 1.0 at all, even escaped, so strip them from strings before converting.

JSON to XML FAQ

How are JSON arrays represented in XML?

As repeated elements with the same name: "tags":["a","b"] becomes <tags>a</tags><tags>b</tags>. Some systems expect a wrapper like <tags><tag>a</tag></tags>; restructure the JSON first if so.

Why does my XML need a single root element?

The XML specification allows exactly one top-level element per document. When the JSON object has several keys, they are placed inside a wrapper root.

Can JSON keys contain characters that XML names cannot?

Yes. XML names cannot start with a digit or contain spaces, while JSON keys can be any string. Such keys are renamed in the output so the XML stays well-formed.

Does the XML output include a schema or types?

No. The values are plain text. If the receiver validates against an XSD, compare the generated element names and order with the schema.

Is the conversion reversible?

Not exactly. A one-item array and a single value look the same in XML, and numbers come back as text unless the reverse converter guesses types.

Related tools