json

FormatValidateConvert

JSON to XML converter

Result· read-only

—XML

The result appears here.

Convert

JSON to XML converter.

Your document never leaves the browser.

JSON to XML with @ keys as attributes and null as xsi:nil — in your browser.

Paste JSON and get well-formed XML, written the way XML to JSON reads it back — so the round trip keeps what XML can hold.

xsi:nil

is how null is written, so it reads back as null

_x0020_

the style an illegal name is encoded in, and decoded back

0

bytes leave your machine

The mapping

1

The JSON

{
  "order": {
    "@id": "7",
    "item": ["pen", "ink"]
  }
}
2

The XML it gives, at the default settings

<?xml version="1.0" encoding="UTF-8"?>
<order id="7">
  <item>pen</item>
  <item>ink</item>
</order>

Mapping

The root element

An object with exactly one key, whose value is not an array, names the root element. Anything else is wrapped in a root element you name under Root element (root by default), and the result says it was added.

Mapping

Attributes and text

"@name" keys with a plain value become attributes; "#text" becomes text; every other key becomes a child element, in key order.

Mapping

Arrays repeat

An array becomes one repeated element per item. An array directly inside an array has no name to repeat, so its items are written as <item>, with a notice.

Mapping

Numbers and booleans

Numbers are written with their exact digits; booleans as true and false.

Mapping

Declaration and indent

The output starts with an XML declaration and is indented at the Settings ⚙ width — 2 spaces when that is a tab.

Null, names and escaping

With Write null as xsi:nil on (the default), null becomes <a xsi:nil="true"/>, with the namespace declared once on the root, so it reads back as null. Off, it is an empty element, and the notice says those nulls come back as "".

A key that is not a legal XML name — first name, 2fa, an empty key — is encoded in the _x0020_ style XmlConvert uses, and decoded again on the way back. The result counts them. Text and attribute values are escaped, including line breaks and tabs in attributes that XML would otherwise normalise away.

1

A key with a space in it, and a null

{
  "user": {
    "first name": "Ada",
    "email": null
  }
}
2

The XML it gives, at the default settings

<?xml version="1.0" encoding="UTF-8"?>
<user xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <first_x0020_name>Ada</first_x0020_name>
  <email xsi:nil="true"/>
</user>

What does not survive, and what is refused

An empty array writes nothing, so its key disappears; a repeated key becomes repeated elements and reads back as an array. Types do not survive the round trip unless Detect numbers and booleans is on when reading back. Each of these is noted when it happens. A string holding a character XML 1.0 cannot represent at all, such as U+0000, is refused with its location.

  • a character XML 1.0 cannot represent at all

A string holding U+0000

{
  "note": "a\u0000b"
}

✕ Line 2, column 11: XML cannot hold U+0000 at all.

Private by construction

The conversion runs in your browser, in the same engine the editor uses. The document is never uploaded, never logged and never leaves your machine — there is no server to send it to. Once the page has loaded it keeps working with the connection off.

Going the other way?

FAQ

Frequently asked questions

Didn’t find your answer?Write to us on the contact page →
How do I make an attribute?

Prefix the key with @: {"book": {"@id": "b1", "title": "Dune"}} writes <book id="b1"><title>Dune</title></book>.

Can I choose the root element?

Yes, when one has to be added. A document that already has a single root key uses that key.

Are the options remembered?

Yes, and they are shared with the editor’s JSON to XML panel.

Keyboard shortcuts

Send feedback

Questions, bug reports and feature requests are all welcome. A bug report is easiest to act on with the shape of the document that caused it — never send anything confidential.

Email us

Contact page, in a new tab, so this page stays as it is.

Settings

Indent

The result is written with it — YAML and XML at 2 spaces when it is Tab.

Code text size
14 px

Both panes.

Wrap long lines

Load from a URL

Your browser fetches it directly — the request goes to that site, never to us.