JSON to XML

Paste JSON and get well formed, indented XML. Arrays become repeated elements, keys starting with @ become attributes and characters like & and < are escaped.

Free and private. Everything runs in your browser, nothing is uploaded.

How it works

  1. Paste or open a filePaste your data into the input box or open a file. Sample shows an example.
  2. Check the resultThe converted data appears on the right as you type. Errors show the line and column.
  3. Copy, download or swapCopy the result, save it as a file, or press Swap to convert it back.

Rules for well formed XML

If the JSON is an object with a single key, that key becomes the root element. Otherwise everything is wrapped in a root element whose name you can set. An array becomes one element per item with the name of its key, so "tag": ["a", "b"] becomes two <tag> elements. A list at the top level is written as <item> elements.

XML names cannot contain spaces or start with a digit, so such keys are adjusted, for example first name becomes first_name, and the tool lists every key it had to change. Null and empty text become empty elements like <note/>. Special characters are escaped, and control characters that XML does not allow are removed. The output uses the same @ and #text rules as XML to JSON, so data can travel both ways.

About JSON

JSON (JavaScript Object Notation) writes data as objects in curly braces, lists in square brackets, text in double quotes, numbers, true, false and null. Almost every API and programming language reads it.

About XML

XML (Extensible Markup Language) stores data in nested elements with opening and closing tags, and can add attributes to each element. It is common in feeds, e-invoices, Office files and SOAP services.

Frequently asked questions

Can I add attributes?

Yes. Start the key with @, for example "@id": 5, and it is written as id="5" on the element. Put the element's text under #text.

Is my data uploaded?

No. The conversion runs in your browser. Configuration files with passwords or keys never leave your device.

Why is yes still text in my JSON?

In YAML 1.2, the current version, only true and false are booleans. Older YAML 1.1 tools also read yes, no, on and off as booleans. Turn on the YAML 1.1 option if your file was written for such a tool.

What happens with several YAML documents?

If the input has more than one document, each starting with a line of three hyphens, the JSON result is a list with one item per document.

How are XML attributes shown in JSON?

Attributes get an @ in front of their name, for example @id. If an element has attributes and text, the text goes into #text. You can choose another prefix for attributes.

Does it work offline?

Yes. After you open the page once, it keeps working without an internet connection.