JSON to XML Converter.

Convert JSON to clean XML in one click — control attributes vs elements, name the root and array items, and pretty-print or minify. All private, in your browser.

No signup · No uploads · No public sharing

XML output

Convert JSON to XML online — free and private

A JSON to XML converter rewrites JSON data as XML markup for enterprise systems, SOAP APIs, RSS, and legacy integrations. Paste your JSON above, press Convert to XML, and the tool produces well-formed, indented XML. Because it runs client-side, you can convert JSON to XML online without ever uploading or publicly sharing your data.

How to convert JSON to XML in three steps

  1. Paste your JSON into the input, or click “Load sample”.
  2. Choose your options — root name, array-item name, indent, and whether to include the XML declaration.
  3. Convert and export — copy the XML or download it as data.xml.

Attributes, elements, and text content

Good XML uses attributes as well as elements, so this converter maps any key beginning with @ to an attribute and a #text key to the element's text content. That gives you real control over the shape of the output instead of forcing every value into a child element. You also set the root element name and the element name used for array items.

This JSON:

{
  "book": {
    "@id": "1",
    "@lang": "en",
    "title": "Dune",
    "price": { "@currency": "USD", "#text": "9.99" }
  }
}

produces proper XML rather than a wall of nested elements:

<?xml version="1.0" encoding="UTF-8"?>
<book id="1" lang="en">
  <title>Dune</title>
  <price currency="USD">9.99</price>
</book>

Converters without attribute support would emit <@id>1</@id> or drop the @id altogether — neither of which a real XML consumer will accept.

Why anyone still converts JSON to XML

XML is not fashionable, but it is deeply entrenched: SOAP web services, SAML single sign-on, RSS and Atom feeds, Android layouts, Maven and Spring config, EDI and banking interchange, and most government and healthcare data standards. If you are converting JSON to XML, it is almost always because something on the other side of an integration will accept nothing else — and that something is usually an enterprise system holding data you really should not paste into a random website.

Convert JSON to XML in Python or JavaScript

Python (dicttoxml or xmltodict):

import json, xmltodict

with open("data.json") as f:
    data = json.load(f)

xml = xmltodict.unparse(data, pretty=True)   # @ = attribute, #text = content
open("data.xml", "w").write(xml)

xmltodict.unparse uses the same @ / #text convention as this tool, so output matches. It requires a single root key — wrap your data if it has several.

JavaScript / Node.js (fast-xml-parser):

import { XMLBuilder } from "fast-xml-parser";

const builder = new XMLBuilder({
  ignoreAttributes: false,
  attributeNamePrefix: "@",
  format: true,
});
const xml = builder.build(data);

Common JSON to XML problems (and fixes)

“My XML is invalid and I cannot see why.” Nine times out of ten it is an unescaped & — usually inside a URL. In XML it must be written &amp;. This converter escapes &, <, >, and quotes automatically.

“My key became an invalid tag.” XML element names cannot begin with a digit or contain spaces, so "2024 sales" is not a legal tag. Keys are sanitised into valid names — but if the receiving system expects exact names, rename them in your JSON first.

“My arrays are wrapped oddly.” XML has no array type, so a list has to become repeated elements. Set the array-item name to match what the consumer expects (often item, entry, or record).

“The consumer rejects the declaration.” Toggle the <?xml …?> declaration off — some embedded parsers and fragment consumers refuse it.

Why use this JSON to XML tool?

Some popular converters default to making your data public through a shared link — a genuine privacy risk when the payload is a SOAP request or a SAML assertion. This one is 100% local, with pretty or minified output and no file-size cap. Need the reverse? Use the XML to JSON converter — the two round-trip cleanly thanks to the shared @/#text convention. Related: JSON to YAML, JSON to CSV, JSON validator to check your input, and JSON formatter to tidy it first. Learn more in our guide on how to convert JSON to XML.

FAQ

JSON to XML, answered.

How do I convert JSON to XML online?+

Paste your JSON into the converter above and press Convert to XML. The tool wraps your data in a root element, turns keys into elements, and pretty-prints the result. You can copy it or download a .xml file. Everything runs in your browser, so nothing is uploaded.

Can I control attributes vs elements?+

Yes. Any JSON key that starts with @ becomes an XML attribute on its parent element, and a key named #text becomes the element's text content. So { "book": { "@id": 1, "#text": "Title" } } produces <book id="1">Title</book>. You can also set the root name and the element name used for array items.

How are arrays converted to XML?+

Each array item is emitted as a repeated element. At the top level, items use the array-item name you choose (default item) inside the root; nested arrays repeat their key, so a tags array becomes several <tags> elements.

Is my data kept private?+

Completely. Unlike converters that default to publicly sharing your data via a link, this tool runs 100% client-side. Your JSON is converted locally and is never uploaded, stored, or shared — safe for configuration and private payloads.

Can I minify the XML or drop the declaration?+

Yes. Choose Minify to output XML on a single line with no indentation, and toggle the <?xml …?> declaration on or off to match what your consumer expects.

Why do I still need XML in 2026?+

Because a great deal of infrastructure has not moved. SOAP web services, SAML single sign-on, RSS and Atom feeds, Android layouts, Maven and Spring configuration, EDI and banking interchange, and most government and healthcare data standards are all XML. Converting JSON to XML is usually about feeding a legacy or enterprise system that will not accept anything else.

What happens to keys that are not valid XML element names?+

XML is much stricter than JSON. Element names cannot start with a digit or contain spaces, so a JSON key like "2024 sales" is not a legal tag. Keys are sanitised into valid names during conversion — but if the receiving system expects exact names, rename the keys in your JSON first.

Are special characters escaped correctly?+

Yes. Ampersands, angle brackets, and quotes are escaped to &amp;, &lt;, &gt;, and &quot; so the output is well-formed. This is the most common way hand-built XML breaks — a single unescaped & in a URL makes the whole document invalid.

Can I convert JSON to XML and back again?+

Yes, and it round-trips cleanly if you use the @ and #text convention. Keys prefixed with @ become attributes and #text becomes element content, so converting back with the XML to JSON tool restores the same structure. Without that convention, attributes have nowhere to go and the round trip is lossy.