Skip to content

JSON to XML

Convert a JSON object to XML.

Input
Output

No result

About JSON to XML

This converts a JSON object into an XML document, using the first top-level key as the root element and walking the rest of the structure beneath it. Nested objects become nested elements, and arrays become repeated sibling elements carrying the array's key name.

There is one behaviour you need to know before relying on it: the root element is taken from the first key, and only that key's value is serialised. If your JSON has several top-level keys, the others are not included in the output. Wrapping your data in a single named key is the way to convert a multi-key document — the wrapper becomes the root and everything beneath it is preserved.

Ampersands and angle brackets inside values are escaped, so text that happens to contain markup characters produces valid XML rather than a document that fails to parse. Empty arrays and objects produce empty elements, which is a reasonable representation rather than an error.

There are no settings on the page at all, which is why several XML conventions cannot be expressed in the output: there is no way to request attributes rather than elements, no XML declaration or document type line is emitted, no namespace prefix is applied, and no choice of indentation or of self-closing versus paired empty tags is offered. The mapping is also one-way. An XML document cannot be handed back to this page to recover the JSON — that is a separate converter with its own conventions, and round-tripping through the two will not necessarily return the original because attributes and text content are represented differently in each direction.

How to use JSON to XML

  1. 1 Paste a JSON object. Wrap it in a single key if it has several at the top level.
  2. 2 The XML document appears immediately, with the first key as its root element.
  3. 3 Copy the output into your document, template or integration.

Frequently asked questions

Why is only part of my JSON in the output?

Because the root element comes from the first top-level key, and only that key is serialised. XML documents have exactly one root, so JSON with several top-level keys has to be wrapped first — put your data inside a single named object and that name becomes the root.

What does a JSON array turn into in XML?

Repeated elements sharing the array's key name. An array under the key "item" produces one <item> element per entry, which is the conventional way to express a list in XML and matches how most XML-consuming systems expect to read one.

What happens to special characters in my values?

Ampersands and angle brackets are escaped to entities, so a value containing them produces well-formed XML. Without that step, a stray angle bracket would make the entire document unparseable.

Can I get attributes instead of elements?

Not through this converter — everything becomes an element. Attributes are a common convention in XML but they have no counterpart in JSON, so a mapping between the two has to be chosen, and elements are the choice that loses the least information.

Free, online, and private

Free to use

JSON to XML is completely free. There is no account to create, no login, and no hidden charge or usage limit.

Runs online in your browser

It is a free online tool that runs entirely in your browser. Nothing to download or install — open the page and start using it right away.

Your data stays private

All processing happens locally on your device. Your input is never uploaded, stored, or tracked, so it never leaves your browser.

How JSON to XML behaves in detail

These are the specifics of this implementation — the exact ranges, defaults and fixed settings you are working with.

Parameter Value
Root element the first key of the top-level object only
Arrays the element name is repeated once per item, with no wrapper element around them
Text escaping `&` and `<` are escaped in values; `>` and quotes are not
Formatting no indentation and no XML declaration — elements are concatenated with no newlines
Scalar types written with String(), so null appears as the text null and true as true

Compiled from the implementation of this tool and checked against it by itoolnet.

What JSON to XML does not do

Knowing the edges of a tool saves more time than another list of its features. These are the cases where it will not do what you might expect.

  • Only the first top-level key becomes the root: {"a":1,"b":2} produces <a>1</a> and the entire b branch is discarded, with no error and no note that anything was dropped.
  • Element names are taken verbatim from JSON keys with no validation, so a key containing a space or starting with a digit — {"a b":1} — is emitted as <a b>1</a b>, which is not well-formed XML.
  • An array with no items produces nothing at all, so the key vanishes from the output entirely; no empty parent element is left behind to show that the field existed.
  • There is no pretty-printer and no declaration, so the result is one unwrapped line with no version header, and nesting depth is only visible by reading the tag names yourself.

Tested and documented by itoolnet, the team that builds and maintains this site.

Share & embed this tool

Writing a guide or article? You are welcome to link to JSON to XML with the snippet below. It is free, runs entirely in your browser, and needs no signup.