Free JSON to XML Converter

Free JSON to XML converter. Set the root element name, map @_ keys to attributes, choose indentation and download a well-formed .xml file. 100% private.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideHow JSON Maps to XML - Root Elements, Arrays and Attributes →

About the JSON to XML Converter tool

Many enterprise systems, payment gateways, government portals and older SOAP services still expect XML, while modern apps speak JSON. This JSON to XML converter bridges the gap by turning any JSON document into well-formed, indented XML that you can copy or download as a file.

The conversion uses the XMLBuilder from fast-xml-parser and follows a simple convention. Each key becomes an element, arrays become repeated elements with the same name, keys starting with @_ become attributes and a #text key becomes the element’s text content. You choose the root element name; if your JSON already has a single top-level key, that key is used as the root, unless you switch on “Always wrap in root”. A top-level array is wrapped as <item> elements under the root. Keys that are not valid XML names, such as ones with spaces or starting with a digit, are cleaned automatically so the output stays well-formed, and special characters like & and < are escaped.

Everything is processed in your browser, so order data, customer details and API payloads are never uploaded.

How to use JSON to XML Converter

  1. Paste JSON into the “JSON input” box, open a .json file with “Open file”, or click “Load sample”.
  2. Type the “Root element name” you want, for example order or catalog.
  3. Choose the Indentation and whether to include the XML declaration.
  4. Turn on “Always wrap in root” if you want the root element even when the JSON has a single top-level key.
  5. Click “Copy” or “Download” to save the .xml file.

Features

Custom root element

Name the root yourself, or reuse the single top-level key of your JSON.

Attributes and text nodes

Keys prefixed with @_ become attributes and #text becomes element text.

Arrays as repeated elements

Each array item becomes its own element with the parent key’s name.

Safe element names

Invalid characters in keys are replaced so the XML is always well-formed.

Declaration and indent options

Add or skip <?xml version="1.0"?> and pick 2 spaces, 4 spaces or tabs.

When to use it

  • Build XML request bodies for SOAP or legacy REST APIs from JSON test data.
  • Convert product catalogues to XML feeds for marketplaces.
  • Create XML fixtures for integration tests.
  • Export app settings to XML for systems like Java or .NET config files.
  • Learn how a JSON structure maps to XML elements and attributes.

Frequently asked questions

How do I create XML attributes from JSON?

Prefix the key with @_, for example {"book": {"@_id": "b1", "title": "XML"}} gives <book id="b1"><title>XML</title></book>.

How are JSON arrays converted?

An array under a key produces one element per item, all with that key’s name. A top-level array is placed under the root as repeated <item> elements.

What happens to null and empty values?

Null values become self-closing empty elements such as <note/>.

What if my keys contain spaces or start with a number?

They are not allowed in XML names, so spaces and other invalid characters become underscores and a leading underscore is added where needed.

Is the conversion done locally?

Yes. The XML is built in your browser and your JSON never leaves your device.

Can I convert the XML back to JSON?

Not with this tool, which only builds XML from JSON. You can, however, paste the result into the XML Formatter to validate and re-indent it.

Related tools