JSON ⇄ XML Converter

Convert JSON to XML and XML back to JSON, right in your browser

Paste JSON to get indented XML, or paste XML to get JSON, then press the swap button to go the other way. Keys that start with @ become attributes, #text holds the text of an element that also has attributes or children, and an array becomes repeated elements. A mistake in either format is reported with its line and column where the browser gives one. Everything runs in your browser: your data is never uploaded, and there is no account to create.

Frequently asked questions

Is my data uploaded anywhere?

No. Converting runs in your browser using JavaScript, so your XML and JSON are never sent to a remote server and there is no account to create. The page keeps your last input and your settings in your own browser (localStorage) so they survive a reload; nothing is stored anywhere else.

How do I convert in the other direction?

Use the swap button between the two panes. It flips the direction and moves the result into the input, so you can convert JSON to XML and straight back to check the round trip.

How is JSON mapped to XML?

An object key becomes an element. A key that starts with @ becomes an attribute, and the key #text is the text of an element that also has attributes or children. An array becomes repeated elements with the same name, and null becomes an empty element. Because an XML document has one root element, a JSON object with a single key uses that key as the root; anything else is wrapped in <root>, and a top-level array becomes <item> elements.

How is XML mapped to JSON?

The reverse: attributes become @name keys, repeated sibling elements become an array, CDATA is read as text, and comments and processing instructions are ignored. An empty element becomes null. By default element text and attribute values that look like a number or true/false are converted to that type, but only when writing them back gives the same text, so 1.0 and 007 stay strings. Turn the option off to keep every value as a string. XML has no array marker, so an array with one item reads back as a single value.

Why does converting my JSON to XML fail?

XML element names must start with a letter or underscore and cannot contain spaces, so a key such as "first name" or "1st" is reported by name. XML also cannot represent an array inside an array, or a control character in text.

Is it safe to paste confidential data, such as configuration files with secrets?

Converting never transmits your text, so a confidential file does not leave your machine. You can verify this: open your browser DevTools, switch to the Network tab, and convert something — no request carries your data. Your last input is saved in your browser's localStorage (clear site data to remove it).

Does it cost anything?

No. The converter is free to use with no sign-up and no usage limits.

Turn JSON into code

More JSON tools