JSON to XML Converter

Convert JSON to clean, indented XML in your browser — with predictable element naming rules and a report of any key that had to be renamed. Free, no sign-up — runs locally in your browser.

Your work is auto-saved in this browser only, so a refresh won't lose it. Nothing is uploaded.

Why convert JSON to XML at all?

JSON won the API era, but XML never left the building: SOAP services, RSS and Atom feeds, SVG images, Office documents, SAML assertions, Maven and Android configuration, and a generation of enterprise systems still speak it natively. When a modern JSON-producing system has to hand data to any of those, someone writes the conversion — and writes it carefully, because the two formats do not model data the same way. JSON has objects, arrays and scalars. XML has elements, attributes, text and namespaces. A converter's job is to pick the predictable mapping and to be honest about the places where the mapping is a convention rather than a law.

The mapping rules used here

JSONXML
Object keyChild element with that name
ArrayThe key's element wraps one child element per item, using the array-item name (default item)
String / number / booleanText content, with &, < and > escaped
nullEmpty element with nil="true", so it stays distinct from an empty string
Key that is not a legal XML nameIllegal characters replaced with _ (digit-first names get an _ prefix) — and every rename is reported above the result
Whole documentWrapped in one root element (default root) under an <?xml version="1.0" encoding="UTF-8"?> declaration

Two consequences deserve attention. First, XML produced this way is element-only: nothing becomes an attribute, because JSON gives no signal about which keys deserve to be attributes, and inventing that distinction would change the document's meaning. Second, a top-level JSON array has no key to name its wrapper, so the root element holds the item elements directly — well-formed, and exactly what most XML pipelines expect.

How to use this tool

  1. Paste JSON, upload a .json file, or press Load sample. Conversion also runs automatically as you type.
  2. Name the root element and the array-item element if the defaults (root / item) do not match your target schema.
  3. Read the rename report if one appears — it lists every key that could not be used as an XML name unchanged.
  4. Copy, download or print the XML. If the input is not valid JSON, you get the exact line and column of the error instead of a half-converted document.

Example

This JSON:

{"user":{"name":"Ada & Co","roles":["admin","editor"],"score":null}}

becomes:

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <user>
    <name>Ada &amp; Co</name>
    <roles>
      <item>admin</item>
      <item>editor</item>
    </roles>
    <score nil="true"/>
  </user>
</root>

Frequently asked questions

How are arrays converted to XML?

XML has no array type, so an array becomes a run of sibling elements, one per item, all using the array-item name you choose ("item" by default). An array of objects under the key "user" becomes repeated <item> elements inside <user> — set the item name to something meaningful for your schema, like "user", if you know what the items represent.

What happens to keys that are not legal XML element names?

XML names cannot contain spaces or most punctuation and cannot start with a digit. Illegal characters are replaced with underscores and a name that would start with a digit gets an underscore prefix — and every rename is reported above the result, never applied silently. So "user name" becomes <user_name> and "2fa" becomes <_2fa>, and the tool tells you both happened.

How is null represented in the XML?

As an empty element with a nil attribute: <key nil="true"/>. That keeps null distinguishable from an empty string, which becomes <key></key>. If your target system uses xsi:nil, note the attribute here is a plain nil — adjust it in your schema mapping.

Can this tool produce XML attributes from JSON?

No — every JSON key becomes a child element. JSON has no attribute concept, and guessing which keys 'should' be attributes would change the meaning of the document. If you need attributes, the conversion is your structural draft; promote the relevant elements afterwards in an XML editor.

Is my JSON uploaded to a server?

No. Parsing and serialising happen in your browser. Nothing you paste is sent anywhere — you can disconnect from the network and keep converting. Your draft is stored only in this browser, for seven days.

Can I convert XML back to JSON here?

Not on this page — XML carries constructs JSON cannot hold (attributes, mixed content, namespaces), so a reverse converter has to make opinionated choices that deserve their own tool. This page does the lossless direction for element-based XML documents.

Related tools

Related guides