datapry

JSON to XML

Convert JSON to well-formed XML, with attributes, text nodes and invalid names handled. Runs in your browser, so nothing is uploaded.

Indent

JSON input

XML output

Waiting for input

About this tool

Turn JSON into XML for systems that only accept XML. Keys starting with the attribute prefix become attributes, the text key becomes element text, and arrays become repeated elements. Special characters are escaped, and keys that aren't valid XML names are renamed, with a warning listing what changed.

How to use it

  1. Paste JSON or import a file.
  2. Set the root element name and the attribute and text conventions.
  3. Copy or download the XML.

Example

Input
{"book":{"@_id":"bk101","title":"Clean Code","price":8.99}}
Output
<root>
  <book id="bk101">
    <title>Clean Code</title>
    <price>8.99</price>
  </book>
</root>

Questions

How do I create attributes?
Prefix the key with the attribute prefix, @_ by default. {"book": {"@_id": "bk101"}} becomes <book id="bk101">. Attributes can only hold text, so object values are written as JSON text with a warning.
What happens to keys with spaces?
XML element names can't contain spaces or start with a digit, so "first name" becomes first_name. A warning lists the renamed keys.
Will converting back give me the same JSON?
Not exactly. XML stores everything as text, so numbers and booleans come back as strings unless you turn on type detection in the XML to JSON tool.